feat: 接入一库一工具知识检索

- 编译知识库英文运行名、描述、检索配置和独立 Registration

- 统一最终分数阈值并保持模型上下文、检索事件与引用一致

- 完善 AG-UI 知识库检索运行态与完成态展示
This commit is contained in:
2026-08-29 15:42:21 +08:00
parent 7e1490d5f8
commit be10eabb64
14 changed files with 832 additions and 44 deletions

View File

@@ -54,20 +54,29 @@ function isHiddenToolName(toolName?: string) {
const normalizedName = normalizeToolName(toolName);
return (
normalizedName === 'retrieve_knowledge' ||
normalizedName.startsWith('retrieve_knowledge_') ||
normalizedName === 'context_reload' ||
normalizedName === '__fragment__'
);
}
function isKnowledgeRetrievalToolName(toolName?: string) {
return normalizeToolName(toolName) === 'retrieve_knowledge';
const normalizedName = normalizeToolName(toolName);
return (
normalizedName === 'retrieve_knowledge' ||
normalizedName.startsWith('retrieve_knowledge_')
);
}
function isBlankToolName(toolName?: string) {
return !normalizeToolName(toolName);
}
function knowledgeRetrievalStatusKey(statusKey?: string) {
function knowledgeRetrievalStatusKey(statusKey?: string, roundId?: string) {
const normalizedRoundId = normalizeText(roundId).trim();
if (normalizedRoundId) {
return `knowledge-retrieval:${normalizedRoundId}`;
}
return normalizeText(statusKey).trim() || 'knowledge-retrieval';
}
@@ -659,12 +668,18 @@ export const ChatTimelineBuilder = {
metadata?: ChatTimelineTurnMetadata,
) {
finishAssistantMessage(items, false, metadata?.roundId);
let label = '已检索知识库';
if (status === 'running') {
label = '正在检索知识库';
} else if (status === 'error') {
label = '知识库检索失败';
}
upsertStatus(items, {
...metadata,
label: status === 'running' ? '正在检索知识库' : '已检索知识库',
label,
status,
statusKey: knowledgeRetrievalStatusKey(statusKey),
tone: 'muted',
statusKey: knowledgeRetrievalStatusKey(statusKey, metadata?.roundId),
tone: status === 'error' ? 'danger' : 'muted',
});
},