43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { http } from './client'
|
|
import type { IndustryPack, KnowledgeItem, KnowledgeSearchResult, KnowledgeStats } from '@/types'
|
|
|
|
/** GET /api/knowledge */
|
|
export function getKnowledge(query: { category?: string; keyword?: string } = {}) {
|
|
return http.get<{ list: KnowledgeItem[]; total: number }>('/api/knowledge', { ...query })
|
|
}
|
|
|
|
/** POST /api/knowledge */
|
|
export function createKnowledge(payload: Partial<KnowledgeItem>) {
|
|
return http.post<KnowledgeItem>('/api/knowledge', payload)
|
|
}
|
|
|
|
/** PATCH /api/knowledge/:id */
|
|
export function updateKnowledge(id: string, payload: Partial<KnowledgeItem>) {
|
|
return http.patch<KnowledgeItem>(`/api/knowledge/${id}`, payload)
|
|
}
|
|
|
|
/** DELETE /api/knowledge/:id */
|
|
export function deleteKnowledge(id: string) {
|
|
return http.del<{ success: boolean }>(`/api/knowledge/${id}`)
|
|
}
|
|
|
|
/** POST /api/knowledge/upload */
|
|
export function uploadKnowledgeFiles(files: { name: string; type: string; base64: string }[]) {
|
|
return http.post<{ items: KnowledgeItem[] }>('/api/knowledge/upload', { files })
|
|
}
|
|
|
|
/** POST /api/knowledge/search-test */
|
|
export function knowledgeSearchTest(question: string) {
|
|
return http.post<KnowledgeSearchResult>('/api/knowledge/search-test', { question })
|
|
}
|
|
|
|
/** GET /api/knowledge/stats */
|
|
export function getKnowledgeStats() {
|
|
return http.get<KnowledgeStats>('/api/knowledge/stats')
|
|
}
|
|
|
|
/** GET /api/knowledge/packs */
|
|
export function getIndustryPacks() {
|
|
return http.get<IndustryPack[]>('/api/knowledge/packs')
|
|
}
|