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
@@ -248,3 +248,38 @@ export interface KnowledgeGraph {
|
||||
export async function getKnowledgeGraph() {
|
||||
return parseResponse<KnowledgeGraph>(await apiFetch(`${baseUrl()}/graph`));
|
||||
}
|
||||
|
||||
// --- graph blacklist ---
|
||||
|
||||
export interface GraphBlacklistItem {
|
||||
id: string;
|
||||
label: string;
|
||||
created_by?: string | null;
|
||||
created_at?: string | null;
|
||||
}
|
||||
|
||||
export async function getGraphBlacklist() {
|
||||
const res = await parseResponse<{ items: GraphBlacklistItem[] }>(
|
||||
await apiFetch(`${baseUrl()}/graph/blacklist`),
|
||||
);
|
||||
return res.items;
|
||||
}
|
||||
|
||||
/** Blacklist node labels (entity names / note titles); they disappear from the graph. */
|
||||
export async function addGraphBlacklist(labels: string[]) {
|
||||
return parseResponse<{ added: number; items: GraphBlacklistItem[] }>(
|
||||
await apiFetch(`${baseUrl()}/graph/blacklist`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ labels }),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export async function removeGraphBlacklist(entryId: string) {
|
||||
return parseResponse<{ ok: boolean }>(
|
||||
await apiFetch(`${baseUrl()}/graph/blacklist/${encodeURIComponent(entryId)}`, {
|
||||
method: "DELETE",
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -6,10 +6,12 @@ import {
|
||||
} from "@tanstack/react-query";
|
||||
|
||||
import {
|
||||
addGraphBlacklist,
|
||||
createKnowledgeNote,
|
||||
deleteKnowledgeNote,
|
||||
exportKnowledgeGraph,
|
||||
fetchVaultPage,
|
||||
getGraphBlacklist,
|
||||
getKnowledgeGraph,
|
||||
getKnowledgeNote,
|
||||
ingestKnowledgeFile,
|
||||
@@ -18,6 +20,7 @@ import {
|
||||
listDuplicates,
|
||||
listKnowledgeNotes,
|
||||
mergeKnowledgeNotes,
|
||||
removeGraphBlacklist,
|
||||
resolveNoteWikilinks,
|
||||
searchKnowledge,
|
||||
updateKnowledgeNote,
|
||||
@@ -80,6 +83,32 @@ export function useKnowledgeGraph() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useGraphBlacklist() {
|
||||
return useQuery({
|
||||
queryKey: [...ROOT_KEY, "graph-blacklist"],
|
||||
queryFn: getGraphBlacklist,
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function useGraphBlacklistActions() {
|
||||
const queryClient = useQueryClient();
|
||||
const invalidate = () => {
|
||||
void queryClient.invalidateQueries({ queryKey: [...ROOT_KEY, "graph"] });
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: [...ROOT_KEY, "graph-blacklist"],
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
add: useMutation({ mutationFn: addGraphBlacklist, onSuccess: invalidate }),
|
||||
remove: useMutation({
|
||||
mutationFn: removeGraphBlacklist,
|
||||
onSuccess: invalidate,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
export function useKnowledgeActions() {
|
||||
const queryClient = useQueryClient();
|
||||
const invalidate = () =>
|
||||
|
||||
Reference in new issue
Block a user