Add debug knowledge base

This commit is contained in:
Xin Wang
2026-02-10 10:22:38 +08:00
parent 1462488969
commit 94a562a1d5
2 changed files with 129 additions and 1 deletions

View File

@@ -621,6 +621,37 @@ export const deleteKnowledgeDocument = async (kbId: string, docId: string): Prom
await apiRequest(`/knowledge/bases/${kbId}/documents/${docId}`, { method: 'DELETE' });
};
export type KnowledgeSearchResultItem = {
content: string;
metadata?: {
document_id?: string;
chunk_index?: number;
kb_id?: string;
[key: string]: any;
};
distance?: number;
};
export type KnowledgeSearchResponse = {
query: string;
results: KnowledgeSearchResultItem[];
};
export const searchKnowledgeBase = async (
kbId: string,
query: string,
nResults: number = 5
): Promise<KnowledgeSearchResponse> => {
return apiRequest<KnowledgeSearchResponse>('/knowledge/search', {
method: 'POST',
body: {
kb_id: kbId,
query,
nResults,
},
});
};
export const fetchHistory = async (): Promise<CallLog[]> => {
const [historyResp, assistantsResp] = await Promise.all([
apiRequest<{ list?: AnyRecord[] } | AnyRecord[]>('/history'),