Skip to content

feat: add GeoAI SamGeo text-prompt segmentation factory and QGIS mode#80

Merged
giswqs merged 2 commits into
mainfrom
feat/geoai-segmentation-tool
May 7, 2026
Merged

feat: add GeoAI SamGeo text-prompt segmentation factory and QGIS mode#80
giswqs merged 2 commits into
mainfrom
feat/geoai-segmentation-tool

Conversation

@giswqs

@giswqs giswqs commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

  • New for_geoai factory and geoai_tools exposing SamGeo text-prompt segmentation, with raster output by default and optional regularize/smooth vector conversion.
  • Wires a GeoAI mode into the QGIS chat dock (sample prompts, workflow prompts, factory dispatch, permission gating).
  • Adds unit and integration tests covering the factory surface, permission filtering, and ChatWorker dispatch.

Test plan

  • pre-commit run --all-files
  • pytest tests/ -q
  • Manual smoke test: open the QGIS chat dock, switch to GeoAI mode, run "Segment buildings in the active raster layer".

Adds a for_geoai factory plus geoai_tools that wrap SamGeo text-prompt
segmentation, with raster output by default and optional regularize or
smooth vector conversion. Exposes a GeoAI mode in the QGIS chat dock so
users can segment objects by natural language without leaving QGIS.
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request May 7, 2026 04:31 Inactive
@giswqs giswqs requested a review from Copilot May 7, 2026 04:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new GeoAI integration mode to the GeoAgent + QGIS chat dock, backed by the external GeoAI QGIS plugin’s SamGeo text-prompt segmentation, along with factories and tests.

Changes:

  • Introduces geoai_tools (SamGeo segmentation + vector post-processing tasks) and wires it into a new for_geoai factory.
  • Adds “GeoAI” mode to the QGIS chat dock (sample/workflow prompts, factory dispatch, permission gating, dependency group).
  • Adds unit/integration tests for tool behavior, permission filtering, and ChatWorker mode dispatch.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_geoai_tools.py New tests validating GeoAI tool adapter behavior (missing plugin, metadata, segmentation, vectorization, dedupe).
tests/test_geoagent_factory.py Tests for new for_geoai factory tool registration and permission filtering.
qgis_geoagent/tests/test_whitebox_integration.py Extends chat worker wiring tests to cover GeoAI mode dispatch.
qgis_geoagent/tests/test_startup_performance.py Adds expectation for GeoAI dependency group composition.
qgis_geoagent/open_geoagent/dialogs/chat_dock.py Adds GeoAI mode, prompts, permission gating category, and factory mapping.
qgis_geoagent/open_geoagent/deps_manager.py Adds a lightweight “GeoAI” dependency group delegating heavy deps to GeoAI plugin venv.
geoagent/tools/geoai.py Implements GeoAI tool adapter (lazy imports, dependency gating, segmentation + optional vector output).
geoagent/tools/init.py Exposes geoai_tools from tools package.
geoagent/core/factory.py Adds for_geoai factory, system prompt, tool assembly integration, and permission category.
geoagent/init.py Re-exports for_geoai.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread geoagent/tools/geoai.py Outdated
Comment thread geoagent/tools/geoai.py Outdated
Comment thread geoagent/tools/geoai.py
Comment thread geoagent/core/factory.py
Comment on lines +1085 to +1094
tools, registry = assemble_tools(
context=ctx,
include_qgis=include_qgis,
include_geoai=True,
include_image_generation=True,
geoai_plugin=plugin,
extra_tools=extra_tools,
fast=fast,
permission_profile=permission_profile,
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving include_image_generation=True here intentionally. Every other factory in geoagent/core/factory.py (for_leafmap, for_anymap, for_qgis, for_whitebox, for_nasa_earthdata, for_nasa_opera, for_gee_data_catalogs, for_stac, for_timelapse, for_vantor) enables it as a project-wide default, so flipping it off only for for_geoai would be inconsistent with the rest of the codebase. Happy to revisit project-wide if a maintainer prefers a different default.

Comment thread qgis_geoagent/tests/test_startup_performance.py Outdated
- geoagent/tools/geoai.py: return a structured {"success": False, ...}
  payload when the prompt is missing instead of raising, matching the rest
  of the tool's error contract.
- geoagent/tools/geoai.py: include the caller-supplied output_path in the
  same-turn dedupe key so two calls that explicitly target different output
  paths are not collapsed.
- geoagent/tools/geoai.py: forward output_format to vectorize_mask and
  smooth_vector tasks (previously only sent to raster_to_vector) so the
  caller's requested format is honored consistently. Test expectations
  updated to match.
- qgis_geoagent/tests/test_startup_performance.py: assert the GeoAI
  dependency group equals CORE_RUNTIME_PACKAGES directly instead of
  slicing Core Providers, so reordering provider entries cannot break
  this test.
@github-actions github-actions Bot temporarily deployed to pull request May 7, 2026 04:41 Inactive
@giswqs giswqs merged commit 8a2875d into main May 7, 2026
9 checks passed
@giswqs giswqs linked an issue May 7, 2026 that may be closed by this pull request
@giswqs giswqs deleted the feat/geoai-segmentation-tool branch May 7, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using geoagent with geoai MCP server

2 participants