feat: add knowledge management pages

This commit is contained in:
hailin
2026-07-03 17:58:09 +08:00
parent 99dbb3277a
commit 94f0488341
7 changed files with 608 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
import { apiRequest } from '@/lib/api'
import type { KnowledgeBase, KnowledgeItemInput, KnowledgeSearchResult } from './types'
export function listKnowledgeBases() {
return apiRequest<KnowledgeBase[]>('/knowledge/bases')
}
export function createKnowledgeBase(payload: {
name: string
description: string
scope: string
enabled?: boolean
}) {
return apiRequest<KnowledgeBase>('/knowledge/bases', {
method: 'POST',
body: JSON.stringify({ ...payload, enabled: payload.enabled ?? true })
})
}
export function createKnowledgeItem(payload: KnowledgeItemInput) {
return apiRequest('/knowledge/items', {
method: 'POST',
body: JSON.stringify(payload)
})
}
export function searchKnowledge(query: string, knowledgeBaseId?: number) {
return apiRequest<KnowledgeSearchResult[]>('/knowledge/search', {
method: 'POST',
body: JSON.stringify({
query,
knowledge_base_id: knowledgeBaseId,
limit: 8
})
})
}