Skip to content

Commit 2adbdb5

Browse files
Gemini CLIclaude
andcommitted
feat: categorized map layers, action buttons, file download, planner transfer fix
- Add 'categorized' layer type to MapPanel for per-feature polygon coloring based on property field + color mapping (DRL Opt_Type, Change_Type) - Add category_labels for human-readable legend (耕地/林地/其他) - Fix action buttons (export PDF etc.) using ChainlitAPI.callAction() instead of broken IAction.onClick() in @chainlit/react-client v0.3.1 - Fix DataPanel file click: non-CSV files now open/download via /api/user/files/ - Fix Planner not delegating to sub-agents: explicit transfer_to_agent() instructions in planner prompt (v7.1.2) - Fix _final_map_update overwrite: layer-count comparison prevents summary-referenced old maps from replacing richer configs - Fix PostGIS SRID detection: regex table extraction + ST_SRID fallback - Clean FFI references from optimization/planner prompts and agent descriptions - Add dynamic tool filtering (v7.5.6): intent-based tool category ContextVar - Migrate genai import to google.genai unified SDK Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3f5eaa5 commit 2adbdb5

22 files changed

Lines changed: 823 additions & 246 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ cd frontend && npm install && npm run dev
123123
| | MCP 工具市场 | 配置驱动的 MCP 服务器连接 + 工具聚合 + DB 持久化 + 管理 UI (v7.1) |
124124
| | 分析视角注入 | 用户自定义分析关注点,自动注入 Agent 提示词 (v7.1) |
125125
| | Memory ETL | 管道执行后自动提取关键发现,智能去重,配额管理 (v7.5) |
126+
| | 动态工具加载 | 按意图动态裁剪工具列表 (8 类别 + 10 核心工具),ContextVar + ToolPredicate (v7.5) |
126127
| | 反思循环 | 全部 3 条管道含 LoopAgent 质量反思 (v7.1) |
127128
| **数据融合** | 融合引擎 (MMFE) | 五阶段流水线(画像→评估→对齐→融合→验证),10 种策略,5 种模态 |
128129
| | 语义匹配 | 五层渐进匹配:精确 → 等价组 → 嵌入相似度 → 单位感知 → 模糊 |
@@ -322,7 +323,7 @@ GitHub Actions 工作流(`.github/workflows/ci.yml`)在 push 到 `main`/`dev
322323
| v6.0 | 融合增强(栅格重投影、点云、流数据、语义增强、质量验证) | ✅ 完成 |
323324
| v7.0 | 向量嵌入匹配、LLM 策略路由、地理知识图谱、分布式计算 | ✅ 完成 |
324325
| v7.1 | MCP 管理 UI + DB 持久化、WorkflowEditor、分析视角注入、Prompt 版本管理、工具错误恢复、反思循环推广、端到端 Trace ID | ✅ 完成 |
325-
| v7.5 | Memory ETL 自动提取 ✅、Gemini Context Caching、动态工具加载、MCP 安全加固 + per-User 隔离 | 进行中 |
326+
| v7.5 | Memory ETL 自动提取 ✅、动态工具加载 ✅、Gemini Context Caching、MCP 安全加固 + per-User 隔离 | 进行中 |
326327
| v8.0 | DB 驱动自定义 Skills、RAG 知识库、DAG 工作流、失败学习与自适应、动态模型选择、评估门控 CI | 规划中 |
327328
| v9.0 | 实时协同编辑、边缘部署、数据连接器生态、多 Agent 并行、A2A 智能体互操作、主动探索与发现 | 远期 |
328329

README_en.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ Default login: `admin` / `admin123` (seeded on first run). In-app self-registrat
127127
| | MCP Tool Market | Config-driven MCP server connection + tool aggregation + DB persistence + management UI (v7.1) |
128128
| | Analysis Perspective | User-defined analysis focus, auto-injected into agent prompts (v7.1) |
129129
| | Memory ETL | Auto-extract key findings after pipeline execution, smart dedup, quota management (v7.5) |
130+
| | Dynamic Tool Loading | Intent-based dynamic tool filtering (8 categories + 10 core tools), ContextVar + ToolPredicate (v7.5) |
130131
| | Reflection Loops | All 3 pipelines with LoopAgent quality reflection (v7.1) |
131132
| **Data Fusion** | Fusion Engine (MMFE) | Five-stage pipeline (Profile→Assess→Align→Fuse→Validate), 10 strategies, 5 modalities |
132133
| | Semantic Matching | Five-tier progressive: exact → equivalence groups → embedding similarity → unit-aware → fuzzy |
@@ -327,7 +328,7 @@ GitHub Actions workflow (`.github/workflows/ci.yml`) runs on push to `main`/`dev
327328
| v6.0 | Fusion Improvements (raster reprojection, point cloud, stream, quality) | ✅ Done |
328329
| v7.0 | Vector Embedding, LLM Strategy Routing, Knowledge Graph, Distributed Computing | ✅ Done |
329330
| v7.1 | MCP Management UI + DB Persistence, WorkflowEditor, Analysis Perspective, Prompt Versioning, Tool Error Recovery, Reflection Loop Expansion, End-to-End Trace ID | ✅ Done |
330-
| v7.5 | Memory ETL Auto-Extraction ✅, Gemini Context Caching, Dynamic Tool Loading, MCP Security + per-User Isolation | In Progress |
331+
| v7.5 | Memory ETL Auto-Extraction ✅, Dynamic Tool Loading ✅, Gemini Context Caching, MCP Security + per-User Isolation | In Progress |
331332
| v8.0 | DB-Driven Custom Skills, RAG Knowledge Base, DAG Workflow, Failure Learning & Adaptation, Dynamic Model Selection, Evaluation-Gated CI | Future |
332333
| v9.0 | Real-time Collaboration, Edge Deployment, Data Connectors, Multi-Agent Parallel, A2A Agent Interop, Proactive Exploration & Discovery | Long-term |
333334

data_agent/agent.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
from .spatial_statistics import spatial_autocorrelation, local_moran, hotspot_analysis
8080
from .gis_processors import _generate_output_path, _resolve_path
8181
from .database_tools import T_TABLE_OWNERSHIP
82+
from .tool_filter import intent_tool_predicate
8283

8384
# ---------------------------------------------------------------------------
8485
# Tool filter presets — reusable across agents
@@ -124,8 +125,8 @@
124125

125126
data_exploration_agent = LlmAgent(
126127
name="DataExploration",
127-
instruction=get_prompt("optimization", "data_exploration_agent_instruction"),
128-
description="数据质量审计与治理专家",
128+
instruction=get_prompt("optimization", "data_exploration_opt_instruction"),
129+
description="优化管道数据准备专家",
129130
model=MODEL_STANDARD,
130131
output_key="data_profile",
131132
after_tool_callback=_self_correction_after_tool,
@@ -138,8 +139,8 @@
138139

139140
data_processing_agent = LlmAgent(
140141
name="DataProcessing",
141-
instruction=get_prompt("optimization", "data_processing_agent_instruction"),
142-
description="特征工程与预处理专家",
142+
instruction=get_prompt("optimization", "data_processing_opt_instruction"),
143+
description="优化管道数据预处理专家",
143144
model=MODEL_STANDARD,
144145
output_key="processed_data",
145146
after_tool_callback=_self_correction_after_tool,
@@ -178,7 +179,7 @@
178179
quality_checker_agent = LlmAgent(
179180
name="QualityChecker",
180181
instruction=get_prompt("optimization", "quality_checker_instruction"),
181-
description="分析结果质量审查员。验证FFI/DRL/遥感指标合理性。",
182+
description="分析结果质量审查员。验证DRL优化/遥感指标合理性。",
182183
model=MODEL_FAST,
183184
output_key="quality_verdict",
184185
tools=[approve_quality],
@@ -301,21 +302,21 @@
301302
after_tool_callback=_self_correction_after_tool,
302303
tools=[
303304
ExplorationToolset(tool_filter=_TRANSFORM_TOOLS),
304-
GeoProcessingToolset(),
305-
LocationToolset(),
305+
GeoProcessingToolset(tool_filter=intent_tool_predicate),
306+
LocationToolset(tool_filter=intent_tool_predicate),
306307
DatabaseToolset(tool_filter=_DB_READ_DESCRIBE + ["share_table", "import_to_postgis"]),
307308
FileToolset(),
308309
MemoryToolset(),
309-
AdminToolset(),
310-
RemoteSensingToolset(),
311-
SpatialStatisticsToolset(),
312-
SemanticLayerToolset(),
313-
StreamingToolset(),
314-
TeamToolset(),
315-
DataLakeToolset(),
310+
AdminToolset(tool_filter=intent_tool_predicate),
311+
RemoteSensingToolset(tool_filter=intent_tool_predicate),
312+
SpatialStatisticsToolset(tool_filter=intent_tool_predicate),
313+
SemanticLayerToolset(tool_filter=intent_tool_predicate),
314+
StreamingToolset(tool_filter=intent_tool_predicate),
315+
TeamToolset(tool_filter=intent_tool_predicate),
316+
DataLakeToolset(tool_filter=intent_tool_predicate),
316317
McpHubToolset(pipeline="general"),
317-
FusionToolset(),
318-
KnowledgeGraphToolset(),
318+
FusionToolset(tool_filter=intent_tool_predicate),
319+
KnowledgeGraphToolset(tool_filter=intent_tool_predicate),
319320
] + _arcpy_tools,
320321
)
321322

@@ -411,15 +412,15 @@ def _make_planner_processor(name: str, **overrides) -> LlmAgent:
411412
after_tool_callback=_self_correction_after_tool,
412413
tools=[
413414
ExplorationToolset(tool_filter=_TRANSFORM_TOOLS),
414-
GeoProcessingToolset(),
415-
LocationToolset(),
415+
GeoProcessingToolset(tool_filter=intent_tool_predicate),
416+
LocationToolset(tool_filter=intent_tool_predicate),
416417
RemoteSensingToolset(tool_filter=["describe_raster", "download_lulc", "download_dem"]),
417-
StreamingToolset(),
418+
StreamingToolset(tool_filter=intent_tool_predicate),
418419
DataLakeToolset(tool_filter=_DATALAKE_READ),
419420
DatabaseToolset(tool_filter=["import_to_postgis"]),
420421
McpHubToolset(pipeline="planner"),
421-
FusionToolset(),
422-
KnowledgeGraphToolset(),
422+
FusionToolset(tool_filter=intent_tool_predicate),
423+
KnowledgeGraphToolset(tool_filter=intent_tool_predicate),
423424
] + _arcpy_tools,
424425
)
425426
defaults.update(overrides)
@@ -431,7 +432,7 @@ def _make_planner_analyzer(name: str, **overrides) -> LlmAgent:
431432
defaults = dict(
432433
name=name,
433434
instruction=get_prompt("planner", "planner_analyzer_instruction"),
434-
description="FFI破碎化指数、DRL深度强化学习布局优化、遥感分析、空间统计专家。",
435+
description="DRL深度强化学习布局优化、遥感分析、空间统计专家。",
435436
model=MODEL_STANDARD,
436437
output_key="analysis_report",
437438
disallow_transfer_to_peers=True,
@@ -448,7 +449,7 @@ def _make_planner_visualizer(name: str, **overrides) -> LlmAgent:
448449
name=name,
449450
instruction=get_prompt("planner", "planner_visualizer_instruction"),
450451
description="地理空间可视化专家。交互地图、Choropleth、热力图、气泡图、PNG导出。",
451-
model=MODEL_FAST,
452+
model=MODEL_STANDARD,
452453
output_key="visualizations",
453454
disallow_transfer_to_peers=True,
454455
tools=[
@@ -492,7 +493,7 @@ def _make_planner_visualizer(name: str, **overrides) -> LlmAgent:
492493

493494
analyze_viz_workflow = SequentialAgent(
494495
name="AnalyzeAndVisualize",
495-
description="分析→可视化 一体化工作流。执行FFI/DRL/统计分析后自动生成可视化。",
496+
description="分析→可视化 一体化工作流。执行DRL/统计分析后自动生成可视化。",
496497
sub_agents=[
497498
_make_planner_analyzer("WFAnalyzer"),
498499
_make_planner_visualizer("WFVisualizer"),

0 commit comments

Comments
 (0)