Files
X-Financial/web/src/services/knowledge.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

import { apiRequest } from './api.js'
export function fetchKnowledgeLibrary() {
return apiRequest('/knowledge/library')
}
export function fetchLlmWikiDocumentDetail(documentId) {
return apiRequest(`/knowledge/llm-wiki/documents/${documentId}`)
}
export function updateLlmWikiDocumentSummary(documentId, payload) {
return apiRequest(`/knowledge/llm-wiki/documents/${documentId}`, {
method: 'PATCH',
body: JSON.stringify(payload)
})
}
export function fetchKnowledgeDocument(documentId) {
return apiRequest(`/knowledge/documents/${documentId}`)
}
export function fetchKnowledgeOnlyOfficeConfig(documentId) {
return apiRequest(`/knowledge/documents/${documentId}/onlyoffice-config`)
}
export function uploadKnowledgeDocument({ folder, file }) {
return apiRequest(
`/knowledge/documents?folder=${encodeURIComponent(folder)}&filename=${encodeURIComponent(file.name)}`,
{
method: 'POST',
body: file,
contentType: file.type || 'application/octet-stream'
}
)
}
export function deleteKnowledgeDocument(documentId) {
return apiRequest(`/knowledge/documents/${documentId}`, {
method: 'DELETE'
})
}
export function syncKnowledgeDocumentToLlmWiki({ folder, documentId, force = false }) {
return apiRequest('/knowledge/llm-wiki/sync', {
method: 'POST',
body: JSON.stringify({
folder,
document_ids: documentId ? [documentId] : [],
force
})
})
}
export function fetchKnowledgeDocumentBlob(documentId, disposition = 'inline') {
return apiRequest(`/knowledge/documents/${documentId}/content?disposition=${disposition}`, {
responseType: 'blob',
contentType: null
})
}