Add debug knowledge base
This commit is contained in:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user