feat: add GeoAI SamGeo text-prompt segmentation factory and QGIS mode#80
Conversation
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.
|
🚀 Deployed on https://69fc1806b52244cb799519c2--opengeos.netlify.app |
There was a problem hiding this comment.
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 newfor_geoaifactory. - 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.
| 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, | ||
| ) |
There was a problem hiding this comment.
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.
- 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.
Summary
for_geoaifactory andgeoai_toolsexposing SamGeo text-prompt segmentation, with raster output by default and optional regularize/smooth vector conversion.Test plan
pre-commit run --all-filespytest tests/ -q