-
Notifications
You must be signed in to change notification settings - Fork 2
Knowledge Base and GraphRAG
GIS Data Agent v14.5 — 基于 Google ADK 的 AI 地理空间平台 仓库:https://github.com/zhouning/gisdataagent
知识库 (Knowledge Base) 让您将领域文档(规划文件、政策法规、技术标准等)导入系统,通过语义搜索和 GraphRAG 为 AI 代理提供精准的领域知识上下文。
使用 create_knowledge_base 工具或通过数据面板的 Knowledge Base(知识库) 标签页创建:
创建一个名为"城市规划法规"的知识库
Create a knowledge base named "Urban Planning Regulations"
限制:每个用户最多 10 个知识库。
使用 add_document_to_kb 添加文档。支持的文档格式:
| 格式 | 说明 |
|---|---|
| 自动提取文本内容 | |
| DOCX | Word 文档 |
| TXT | 纯文本文件 |
| MD | Markdown 文档 |
限制:每个知识库最多 50 个文档。
将"城市总体规划2025.pdf"添加到"城市规划法规"知识库
Add "urban_master_plan_2025.pdf" to the "Urban Planning Regulations" knowledge base
search_knowledge_base 使用基于嵌入向量的检索,根据语义相似度返回最相关的文档片段:
在"城市规划法规"知识库中搜索"绿地率要求"
Search "Urban Planning Regulations" for "green space ratio requirements"
返回结果包含:
- 匹配的文档片段
- 相似度分数
- 来源文档和位置信息
get_kb_context 工具为 LLM 响应提供知识库上下文。当代理需要回答专业问题时,自动从知识库检索相关内容作为生成依据:
根据知识库回答:商业用地的容积率上限是多少?
Using the knowledge base, answer: What is the maximum FAR for commercial land?
工作流程:
- 用户提问 → 语义检索相关文档片段
- 检索结果作为上下文注入 LLM 提示词
- LLM 基于检索到的事实生成回答(减少幻觉)
build_kb_graph_tool 从知识库文档中自动提取实体和关系,构建知识图谱:
为"城市规划法规"知识库构建知识图谱
Build a knowledge graph for the "Urban Planning Regulations" knowledge base
提取的实体类型包括:地名、组织、政策、指标、地块编号等。
graph_rag_search_tool 结合图结构进行增强检索,能够发现跨文档的实体关联:
通过图谱搜索:哪些地块涉及生态保护红线?
Graph search: Which parcels overlap with ecological protection red lines?
相比纯语义搜索的优势:
- 多跳推理:通过关系链发现间接关联
- 跨文档关联:将不同文档中的相关实体自动连接
- 上下文丰富度:返回实体的关系网络而非孤立片段
get_kb_entity_graph_tool 返回实体关系数据,可在前端可视化展示:
展示"城市规划法规"知识库的实体关系图谱
Show the entity relationship graph for "Urban Planning Regulations"
以下是一个典型的使用流程:
-
创建知识库
创建知识库"生态保护" -
上传规划文档
添加"生态红线划定报告.pdf"到知识库 添加"自然保护区管理条例.docx"到知识库 -
构建知识图谱
为"生态保护"知识库构建图谱 -
查询
哪些地块涉及生态保护红线? 这些地块有哪些开发限制条件?
系统会自动从知识图谱中检索相关实体(地块、保护区、红线边界),并通过关系推理提供完整答案。
GIS Data Agent v14.5 — AI geospatial platform on Google ADK Repository: https://github.com/zhouning/gisdataagent
The Knowledge Base lets you import domain documents (planning documents, regulations, technical standards, etc.) into the system, providing precise domain knowledge context for AI agents through semantic search and GraphRAG.
Use the create_knowledge_base tool or create one through the Knowledge Base tab in the Data Panel:
创建一个名为"城市规划法规"的知识库
Create a knowledge base named "Urban Planning Regulations"
Limit: Up to 10 knowledge bases per user.
Use add_document_to_kb to add documents. Supported formats:
| Format | Description |
|---|---|
| Automatic text extraction | |
| DOCX | Word documents |
| TXT | Plain text files |
| MD | Markdown documents |
Limit: Up to 50 documents per knowledge base.
将"城市总体规划2025.pdf"添加到"城市规划法规"知识库
Add "urban_master_plan_2025.pdf" to the "Urban Planning Regulations" knowledge base
search_knowledge_base uses embedding-based retrieval to return the most relevant document fragments by semantic similarity:
在"城市规划法规"知识库中搜索"绿地率要求"
Search "Urban Planning Regulations" for "green space ratio requirements"
Results include:
- Matching document fragments
- Similarity scores
- Source document and location information
The get_kb_context tool provides knowledge base context for LLM responses. When agents need to answer specialized questions, relevant content is automatically retrieved from the knowledge base as the generation basis:
根据知识库回答:商业用地的容积率上限是多少?
Using the knowledge base, answer: What is the maximum FAR for commercial land?
Workflow:
- User asks a question → semantic retrieval of relevant document fragments
- Retrieved results are injected as context into the LLM prompt
- LLM generates answers based on retrieved facts (reducing hallucinations)
build_kb_graph_tool automatically extracts entities and relationships from knowledge base documents to build a knowledge graph:
为"城市规划法规"知识库构建知识图谱
Build a knowledge graph for the "Urban Planning Regulations" knowledge base
Extracted entity types include: place names, organizations, policies, metrics, parcel IDs, etc.
graph_rag_search_tool performs enhanced retrieval using graph structure, discovering cross-document entity associations:
通过图谱搜索:哪些地块涉及生态保护红线?
Graph search: Which parcels overlap with ecological protection red lines?
Advantages over pure semantic search:
- Multi-hop reasoning: Discover indirect associations through relationship chains
- Cross-document linking: Automatically connect related entities across different documents
- Context richness: Return entity relationship networks rather than isolated fragments
get_kb_entity_graph_tool returns entity relationship data for frontend visualization:
展示"城市规划法规"知识库的实体关系图谱
Show the entity relationship graph for "Urban Planning Regulations"
Here is a typical usage flow:
-
Create a knowledge base
创建知识库"生态保护" Create knowledge base "Ecological Protection" -
Upload planning documents
添加"生态红线划定报告.pdf"到知识库 Add "ecological_redline_report.pdf" to the knowledge base 添加"自然保护区管理条例.docx"到知识库 Add "nature_reserve_regulations.docx" to the knowledge base -
Build knowledge graph
为"生态保护"知识库构建图谱 Build knowledge graph for "Ecological Protection" -
Query
哪些地块涉及生态保护红线? Which parcels overlap with ecological protection red lines? 这些地块有哪些开发限制条件? What development restrictions apply to these parcels?
The system automatically retrieves relevant entities (parcels, protected areas, red line boundaries) from the knowledge graph and provides comprehensive answers through relationship reasoning.
GIS Data Agent v14.5 · Built on Google ADK · GitHub · Report Issue
快速开始 Getting Started
核心概念 Core Concepts
使用指南 User Guide
架构与运维 Architecture & Ops
参考 Reference