feat: 重构知识库系统,移除Hermes集成,增强RAG和同步功能
主要变更: - 移除Hermes智能体及相关回调服务 - 新增知识库RAG、同步、调度、规范化和索引任务服务 - 重构orchestrator服务,增强运行时聊天功能 - 更新前端聊天、政策制度、设置等页面样式和逻辑 - 更新expense_claims和document_intelligence服务 - 删除llm_wiki相关服务和测试文件 - 更新docker-compose配置和启动脚本
This commit is contained in:
@@ -226,9 +226,11 @@ export async function apiRequest(path, options = {}) {
|
||||
contentType = 'application/json',
|
||||
responseType = 'json',
|
||||
headers: customHeaders,
|
||||
...fetchOptions
|
||||
} = options
|
||||
|
||||
timeoutMs = 0,
|
||||
timeoutMessage = '',
|
||||
...fetchOptions
|
||||
} = options
|
||||
|
||||
const headers = sanitizeHeaders({
|
||||
...readCurrentUserHeaders(),
|
||||
...(customHeaders || {})
|
||||
@@ -237,23 +239,44 @@ export async function apiRequest(path, options = {}) {
|
||||
if (contentType !== null && typeof headers['Content-Type'] === 'undefined') {
|
||||
headers['Content-Type'] = contentType
|
||||
}
|
||||
|
||||
let response
|
||||
|
||||
|
||||
let response
|
||||
let timeoutId = 0
|
||||
let requestOptions = {
|
||||
...fetchOptions,
|
||||
headers
|
||||
}
|
||||
|
||||
if (!fetchOptions.signal && Number(timeoutMs) > 0 && typeof AbortController !== 'undefined') {
|
||||
const controller = new AbortController()
|
||||
timeoutId = globalThis.setTimeout(() => controller.abort(), Number(timeoutMs))
|
||||
requestOptions = {
|
||||
...requestOptions,
|
||||
signal: controller.signal
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
response = await fetch(buildUrl(path), {
|
||||
...fetchOptions,
|
||||
headers
|
||||
})
|
||||
response = await fetch(buildUrl(path), requestOptions)
|
||||
} catch (error) {
|
||||
if (timeoutId) {
|
||||
globalThis.clearTimeout(timeoutId)
|
||||
}
|
||||
if (error?.name === 'AbortError') {
|
||||
throw new Error(String(timeoutMessage || '').trim() || '接口请求超时,请稍后重试。')
|
||||
}
|
||||
if (String(error?.message || '').includes('ByteString')) {
|
||||
throw new Error('当前登录用户信息包含浏览器不支持的请求头字符,请重新登录后重试。')
|
||||
}
|
||||
|
||||
throw new Error('无法连接 FastAPI 后端服务,请确认后端已启动且浏览器可访问后端端口。')
|
||||
}
|
||||
|
||||
if (responseType === 'blob') {
|
||||
|
||||
if (timeoutId) {
|
||||
globalThis.clearTimeout(timeoutId)
|
||||
}
|
||||
|
||||
if (responseType === 'blob') {
|
||||
if (!response.ok) {
|
||||
let payload = null
|
||||
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
import { apiRequest } from './api.js'
|
||||
|
||||
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}`)
|
||||
}
|
||||
@@ -40,12 +29,12 @@ export function deleteKnowledgeDocument(documentId) {
|
||||
})
|
||||
}
|
||||
|
||||
export function syncKnowledgeDocumentToLlmWiki({ folder, documentId, force = false }) {
|
||||
return apiRequest('/knowledge/llm-wiki/sync', {
|
||||
export function syncKnowledgeLibrary({ folder, documentIds = [], force = false }) {
|
||||
return apiRequest('/knowledge/sync', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
folder,
|
||||
document_ids: documentId ? [documentId] : [],
|
||||
document_ids: Array.isArray(documentIds) ? documentIds : [],
|
||||
force
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { apiRequest } from './api.js'
|
||||
|
||||
export function runOrchestrator(payload) {
|
||||
export function runOrchestrator(payload, options = {}) {
|
||||
return apiRequest('/orchestrator/run', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload)
|
||||
body: JSON.stringify(payload),
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user