| | |
| | | id: number; // 编号 |
| | | knowledgeId: number; // 知识库编号 |
| | | name: string; // 文档名称 |
| | | url: string; // 文档 URL |
| | | contentLength: number; // 字符数 |
| | | tokens: number; // token 数 |
| | | segmentMaxTokens: number; // 分片最大 token 数 |
| | | retrievalCount: number; // 召回次数 |
| | | status: number; // 是否启用 |
| | | } |
| | | |
| | | export interface CreateDocumentParams { |
| | | knowledgeId: number; |
| | | name: string; |
| | | url: string; |
| | | } |
| | | |
| | | export interface CreateDocumentListParams { |
| | | knowledgeId: number; |
| | | segmentMaxTokens: number; |
| | | list: Array<{ name: string; url: string }>; |
| | | } |
| | | |
| | | export interface UpdateDocumentParams { |
| | | id: number; |
| | | name?: string; |
| | | url?: string; |
| | | segmentMaxTokens?: number; |
| | | } |
| | | |
| | | export interface UpdateDocumentStatusParams { |
| | | id: number; |
| | | status: number; |
| | | } |
| | | |
| | | export interface DocumentProgress { |
| | | documentId: number; |
| | | count: number; |
| | | embeddingCount: number; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | /** 查询知识库文档详情 */ |
| | | export function getKnowledgeDocument(id: number) { |
| | | return requestClient.get(`/ai/knowledge/document/get?id=${id}`); |
| | | return requestClient.get<AiKnowledgeDocumentApi.KnowledgeDocument>( |
| | | `/ai/knowledge/document/get?id=${id}`, |
| | | ); |
| | | } |
| | | |
| | | /** 新增知识库文档(单个) */ |
| | | export function createKnowledge(data: any) { |
| | | export function createKnowledge(data: AiKnowledgeDocumentApi.CreateDocumentParams) { |
| | | return requestClient.post('/ai/knowledge/document/create', data); |
| | | } |
| | | |
| | | /** 新增知识库文档(多个) */ |
| | | export function createKnowledgeDocumentList(data: any) { |
| | | export function createKnowledgeDocumentList( |
| | | data: AiKnowledgeDocumentApi.CreateDocumentListParams, |
| | | ) { |
| | | return requestClient.post('/ai/knowledge/document/create-list', data); |
| | | } |
| | | |
| | | /** 修改知识库文档 */ |
| | | export function updateKnowledgeDocument(data: any) { |
| | | export function updateKnowledgeDocument( |
| | | data: AiKnowledgeDocumentApi.UpdateDocumentParams, |
| | | ) { |
| | | return requestClient.put('/ai/knowledge/document/update', data); |
| | | } |
| | | |
| | | /** 修改知识库文档状态 */ |
| | | export function updateKnowledgeDocumentStatus(data: any) { |
| | | export function updateKnowledgeDocumentStatus( |
| | | data: AiKnowledgeDocumentApi.UpdateDocumentStatusParams, |
| | | ) { |
| | | return requestClient.put('/ai/knowledge/document/update-status', data); |
| | | } |
| | | |
| | |
| | | export function deleteKnowledgeDocument(id: number) { |
| | | return requestClient.delete(`/ai/knowledge/document/delete?id=${id}`); |
| | | } |
| | | |
| | | /** 处理文档(分段+向量化) */ |
| | | export function processDocument(id: number) { |
| | | return requestClient.post(`/ai/knowledge/document/process/${id}`); |
| | | } |
| | | |
| | | /** 查询文档处理进度 */ |
| | | export function getDocumentProgress(documentIds: number[]) { |
| | | return requestClient.get<AiKnowledgeDocumentApi.DocumentProgress[]>( |
| | | '/ai/knowledge/document/progress', |
| | | { params: { documentIds: documentIds.join(',') } }, |
| | | ); |
| | | } |