feat: 完善知识图谱交互与 Agent/线程持久化
- 知识图谱画布、侧边栏、详情面板交互优化,新增图谱相关 API 与 hooks - Agent 卡片与详情面板调整,对话页面重构 - 线程元数据持久化增强(base/memory/sql),knowledge 仓储与导出补充 - 网关路由 agents/knowledge/threads 同步更新 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ea78fe9726
commit
f107ebc46d
25 files changed
+929
-279
No files matched your search
@@ -796,7 +796,8 @@ class KnowledgeService:
|
||||
notes = await self.repo.list_all()
|
||||
entities = await self.repo.list_entities() if self.config.entity_extraction_enabled else []
|
||||
relations = await self.repo.list_relations() if self.config.entity_extraction_enabled else []
|
||||
result = self.adapter.export_graph(notes, entities=entities, relations=relations, updated=now_iso())
|
||||
blacklist = await self._graph_blacklist_set()
|
||||
result = self.adapter.export_graph(notes, entities=entities, relations=relations, updated=now_iso(), blacklist=blacklist)
|
||||
return {"files": result["files"], "stats": result["stats"]}
|
||||
|
||||
async def get_graph(self) -> dict[str, Any]:
|
||||
@@ -806,7 +807,26 @@ class KnowledgeService:
|
||||
notes = await self.repo.list_all()
|
||||
entities = await self.repo.list_entities() if self.config.entity_extraction_enabled else []
|
||||
relations = await self.repo.list_relations() if self.config.entity_extraction_enabled else []
|
||||
return exporter.build_graph(notes, entities, relations)
|
||||
blacklist = await self._graph_blacklist_set()
|
||||
return exporter.build_graph(notes, entities, relations, blacklist=blacklist)
|
||||
|
||||
# -- graph blacklist ---------------------------------------------------
|
||||
async def _graph_blacklist_set(self) -> set[str]:
|
||||
from deerflow.knowledge import exporter
|
||||
|
||||
items = await self.repo.list_graph_blacklist()
|
||||
return exporter.normalize_blacklist([item["label"] for item in items])
|
||||
|
||||
async def list_graph_blacklist(self) -> list[dict[str, Any]]:
|
||||
"""Return blacklist entries (node labels hidden from the graph)."""
|
||||
return await self.repo.list_graph_blacklist()
|
||||
|
||||
async def add_graph_blacklist(self, labels: list[str], *, created_by: str | None = None) -> int:
|
||||
"""Blacklist node labels (entity names / note titles). Returns the count added."""
|
||||
return await self.repo.add_graph_blacklist(labels, created_by=created_by)
|
||||
|
||||
async def remove_graph_blacklist(self, entry_id: str) -> bool:
|
||||
return await self.repo.remove_graph_blacklist(entry_id)
|
||||
|
||||
def export_file_path(self, filename: str) -> Path | None:
|
||||
return self.adapter.export_file_path(filename)
|
||||
Reference in new issue
Block a user