fix(quick-qa): distinguish web and knowledge base retrieval in pipeline UI
Emit search_source metadata from RAG progress events so quick-answer steps, summaries, and IM labels no longer mislabel web-only results as knowledge base search.
This commit is contained in:
@@ -107,6 +107,7 @@ const messages = {
|
||||
"deepThoughtAlt": "深度思考完成",
|
||||
"referencesTitle": "参考了{count}个相关内容",
|
||||
"referencesDocCount": "引用了{count}篇文档",
|
||||
"referencesWebCount": "参考了{count}条网页",
|
||||
"referencesDocAndWebCount": "引用了{docCount}篇文档和{webCount}条网页",
|
||||
"referenceChunkCount": "{count}个片段",
|
||||
"fallbackHint": "未从知识库中检索到相关内容,以上为模型直接回答",
|
||||
@@ -357,7 +358,8 @@ const messages = {
|
||||
"noResults": "未找到匹配的内容",
|
||||
"foundResultsFromFiles": "找到 {count} 个结果,来自 {files} 个文件",
|
||||
"foundResults": "找到 {count} 个结果",
|
||||
"webResults": "找到 {count} 个网络搜索结果",
|
||||
"foundMixedResults": "找到 {count} 个结果({docCount} 篇文档,{webCount} 条网页)",
|
||||
"webResults": "找到 {count} 条网页",
|
||||
"grepSummary": "找到 {chunks} 个匹配片段,来自 {docs} 个文档"
|
||||
},
|
||||
"grepResults": {
|
||||
@@ -375,6 +377,10 @@ const messages = {
|
||||
"understandDone": "已完成问题理解",
|
||||
"searching": "正在检索知识库...",
|
||||
"searchingWithQuery": "正在检索知识库:「{query}」",
|
||||
"searchingWeb": "正在检索网络...",
|
||||
"searchingWebWithQuery": "正在检索网络:「{query}」",
|
||||
"searchingMixed": "正在检索知识库和网络...",
|
||||
"searchingMixedWithQuery": "正在检索知识库和网络:「{query}」",
|
||||
"searchDone": "检索完成",
|
||||
"searchDoneWithQuery": "检索知识库:「{query}」",
|
||||
"referencedDocs": "引用 <strong>{count}</strong> 篇文档",
|
||||
@@ -385,6 +391,8 @@ const messages = {
|
||||
"calling": "正在调用 {name}...",
|
||||
"searchKb": "检索知识库",
|
||||
"searchKbFailed": "检索知识库失败",
|
||||
"searchMixed": "检索知识库和网络",
|
||||
"searchMixedFailed": "检索失败",
|
||||
"webSearch": "网络搜索",
|
||||
"webSearchFailed": "网络搜索失败",
|
||||
"grepSearch": "搜索关键词",
|
||||
@@ -571,6 +579,7 @@ const messages = {
|
||||
"deepThoughtAlt": "Deep thinking finished",
|
||||
"referencesTitle": "Referenced {count} related item(s)",
|
||||
"referencesDocCount": "Referenced {count} document(s)",
|
||||
"referencesWebCount": "Referenced {count} web result(s)",
|
||||
"referencesDocAndWebCount": "Referenced {docCount} document(s) and {webCount} web page(s)",
|
||||
"referenceChunkCount": "{count} chunk(s)",
|
||||
"fallbackHint": "No relevant content found in knowledge base. Above is a direct response from the model.",
|
||||
@@ -822,7 +831,8 @@ const messages = {
|
||||
"noResults": "No matching content found",
|
||||
"foundResultsFromFiles": "Found {count} result(s) from {files} file(s)",
|
||||
"foundResults": "Found {count} result(s)",
|
||||
"webResults": "Found {count} web search result(s)",
|
||||
"foundMixedResults": "Found {count} result(s) ({docCount} documents, {webCount} web results)",
|
||||
"webResults": "Found {count} web result(s)",
|
||||
"grepSummary": "Found {chunks} matching chunk(s) across {docs} document(s)"
|
||||
},
|
||||
"grepResults": {
|
||||
@@ -840,6 +850,10 @@ const messages = {
|
||||
"understandDone": "Query understood",
|
||||
"searching": "Searching knowledge base...",
|
||||
"searchingWithQuery": "Searching knowledge base: \"{query}\"",
|
||||
"searchingWeb": "Searching the web...",
|
||||
"searchingWebWithQuery": "Searching the web: \"{query}\"",
|
||||
"searchingMixed": "Searching knowledge base and web...",
|
||||
"searchingMixedWithQuery": "Searching knowledge base and web: \"{query}\"",
|
||||
"searchDone": "Search complete",
|
||||
"searchDoneWithQuery": "Searched knowledge base: \"{query}\"",
|
||||
"referencedDocs": "Cited <strong>{count}</strong> documents",
|
||||
@@ -850,6 +864,8 @@ const messages = {
|
||||
"calling": "Calling {name}...",
|
||||
"searchKb": "Searching knowledge base",
|
||||
"searchKbFailed": "Knowledge base search failed",
|
||||
"searchMixed": "Searched knowledge base and web",
|
||||
"searchMixedFailed": "Search failed",
|
||||
"webSearch": "Web search",
|
||||
"webSearchFailed": "Web search failed",
|
||||
"grepSearch": "Keyword search",
|
||||
|
||||
@@ -3056,6 +3056,7 @@ export default {
|
||||
deepThoughtAlt: 'Deep thinking finished',
|
||||
referencesTitle: 'Referenced {count} related item(s)',
|
||||
referencesDocCount: 'Referenced {count} document(s)',
|
||||
referencesWebCount: 'Referenced {count} web result(s)',
|
||||
referencesDocAndWebCount: 'Referenced {docCount} document(s) and {webCount} web page(s)',
|
||||
referenceChunkCount: '{count} chunk(s)',
|
||||
fallbackHint: 'No relevant content found in knowledge base. Above is a direct response from the model.',
|
||||
@@ -5134,7 +5135,8 @@ export default {
|
||||
noResults: 'No matching content found',
|
||||
foundResultsFromFiles: 'Found {count} result(s) from {files} file(s)',
|
||||
foundResults: 'Found {count} result(s)',
|
||||
webResults: 'Found {count} web search result(s)',
|
||||
foundMixedResults: 'Found {count} result(s) ({docCount} documents, {webCount} web results)',
|
||||
webResults: 'Found {count} web result(s)',
|
||||
grepSummary: 'Found {chunks} matching chunk(s) across {docs} document(s)',
|
||||
},
|
||||
grepResults: {
|
||||
@@ -5152,6 +5154,10 @@ export default {
|
||||
understandDone: 'Query understood',
|
||||
searching: 'Searching knowledge base...',
|
||||
searchingWithQuery: 'Searching knowledge base: "{query}"',
|
||||
searchingWeb: 'Searching the web...',
|
||||
searchingWebWithQuery: 'Searching the web: "{query}"',
|
||||
searchingMixed: 'Searching knowledge base and web...',
|
||||
searchingMixedWithQuery: 'Searching knowledge base and web: "{query}"',
|
||||
searchDone: 'Search complete',
|
||||
searchDoneWithQuery: 'Searched knowledge base: "{query}"',
|
||||
referencedDocs: 'Cited <strong>{count}</strong> documents',
|
||||
@@ -5162,6 +5168,8 @@ export default {
|
||||
calling: 'Calling {name}...',
|
||||
searchKb: 'Searching knowledge base',
|
||||
searchKbFailed: 'Knowledge base search failed',
|
||||
searchMixed: 'Searched knowledge base and web',
|
||||
searchMixedFailed: 'Search failed',
|
||||
webSearch: 'Web search',
|
||||
webSearchFailed: 'Web search failed',
|
||||
grepSearch: 'Keyword search',
|
||||
|
||||
@@ -924,6 +924,7 @@ export default {
|
||||
deepThoughtAlt: "심층 분석 완료",
|
||||
referencesTitle: "{count}개의 관련 내용 참조",
|
||||
referencesDocCount: "{count}개 문서 참조",
|
||||
referencesWebCount: "{count}개 웹 결과 참조",
|
||||
referencesDocAndWebCount: "{docCount}개 문서와 {webCount}개 웹페이지 참조",
|
||||
referenceChunkCount: "{count}개 청크",
|
||||
fallbackHint: "지식 베이스에서 관련 내용을 찾지 못했습니다. 위는 모델의 직접 응답입니다.",
|
||||
@@ -5150,7 +5151,8 @@ export default {
|
||||
noResults: '일치하는 내용을 찾을 수 없습니다',
|
||||
foundResultsFromFiles: '{files}개 파일에서 {count}개 결과 발견',
|
||||
foundResults: '{count}개 결과 발견',
|
||||
webResults: '{count}개 웹 검색 결과 발견',
|
||||
foundMixedResults: '{count}개 결과 발견 ({docCount}개 문서, {webCount}개 웹)',
|
||||
webResults: '웹 결과 {count}개 발견',
|
||||
grepSummary: '일치하는 청크 {chunks}개, 문서 {docs}개',
|
||||
},
|
||||
grepResults: {
|
||||
@@ -5167,6 +5169,10 @@ export default {
|
||||
understandDone: '질문 이해 완료',
|
||||
searching: '지식베이스 검색 중...',
|
||||
searchingWithQuery: '지식베이스 검색 중: 「{query}」',
|
||||
searchingWeb: '웹 검색 중...',
|
||||
searchingWebWithQuery: '웹 검색 중: 「{query}」',
|
||||
searchingMixed: '지식베이스 및 웹 검색 중...',
|
||||
searchingMixedWithQuery: '지식베이스 및 웹 검색 중: 「{query}」',
|
||||
searchDone: '검색 완료',
|
||||
searchDoneWithQuery: '지식베이스 검색: 「{query}」',
|
||||
},
|
||||
@@ -5174,6 +5180,8 @@ export default {
|
||||
calling: '{name} 호출 중...',
|
||||
searchKb: '지식베이스 검색',
|
||||
searchKbFailed: '지식베이스 검색 실패',
|
||||
searchMixed: '지식베이스 및 웹 검색',
|
||||
searchMixedFailed: '검색 실패',
|
||||
webSearch: '웹 검색',
|
||||
webSearchFailed: '웹 검색 실패',
|
||||
grepSearch: '키워드 검색',
|
||||
|
||||
@@ -3429,6 +3429,7 @@ export default {
|
||||
summaryInProgress: 'Идёт подготовка ответа…',
|
||||
referencesTitle: 'Использовано {count} связанного материала',
|
||||
referencesDocCount: 'Использовано {count} документ(ов)',
|
||||
referencesWebCount: 'Использовано {count} веб-результат(ов)',
|
||||
referencesDocAndWebCount: 'Использовано {docCount} документ(ов) и {webCount} веб-страниц(ы)',
|
||||
referenceChunkCount: '{count} фрагмент(ов)',
|
||||
fallbackHint: 'В базе знаний не найдено релевантного содержимого. Выше представлен прямой ответ модели.',
|
||||
@@ -4650,7 +4651,8 @@ export default {
|
||||
noResults: 'Совпадения не найдены',
|
||||
foundResultsFromFiles: 'Найдено {count} результат(ов) из {files} файл(ов)',
|
||||
foundResults: 'Найдено {count} результат(ов)',
|
||||
webResults: 'Найдено {count} результат(ов) веб-поиска',
|
||||
foundMixedResults: 'Найдено {count} результат(ов) ({docCount} док., {webCount} веб)',
|
||||
webResults: 'Найдено {count} веб-результат(ов)',
|
||||
grepSummary: 'Найдено фрагментов: {chunks}, в документах: {docs}',
|
||||
},
|
||||
grepResults: {
|
||||
@@ -4667,6 +4669,10 @@ export default {
|
||||
understandDone: 'Запрос понят',
|
||||
searching: 'Поиск в базе знаний...',
|
||||
searchingWithQuery: 'Поиск в базе знаний: «{query}»',
|
||||
searchingWeb: 'Поиск в сети...',
|
||||
searchingWebWithQuery: 'Поиск в сети: «{query}»',
|
||||
searchingMixed: 'Поиск в базе знаний и сети...',
|
||||
searchingMixedWithQuery: 'Поиск в базе знаний и сети: «{query}»',
|
||||
searchDone: 'Поиск завершён',
|
||||
searchDoneWithQuery: 'Поиск в базе знаний: «{query}»',
|
||||
},
|
||||
@@ -4674,6 +4680,8 @@ export default {
|
||||
calling: 'Вызов {name}...',
|
||||
searchKb: 'Поиск по базе знаний',
|
||||
searchKbFailed: 'Ошибка поиска по базе знаний',
|
||||
searchMixed: 'Поиск в базе знаний и сети',
|
||||
searchMixedFailed: 'Ошибка поиска',
|
||||
webSearch: 'Веб-поиск',
|
||||
webSearchFailed: 'Ошибка веб-поиска',
|
||||
grepSearch: 'Поиск по ключевым словам',
|
||||
|
||||
@@ -922,6 +922,7 @@ export default {
|
||||
deepThoughtAlt: "深度思考完成",
|
||||
referencesTitle: "参考了{count}个相关内容",
|
||||
referencesDocCount: "引用了{count}篇文档",
|
||||
referencesWebCount: "参考了{count}条网页",
|
||||
referencesDocAndWebCount: "引用了{docCount}篇文档和{webCount}条网页",
|
||||
referenceChunkCount: "{count}个片段",
|
||||
fallbackHint: "未从知识库中检索到相关内容,以上为模型直接回答",
|
||||
@@ -5147,7 +5148,8 @@ export default {
|
||||
noResults: "未找到匹配的内容",
|
||||
foundResultsFromFiles: "找到 {count} 个结果,来自 {files} 个文件",
|
||||
foundResults: "找到 {count} 个结果",
|
||||
webResults: "找到 {count} 个网络搜索结果",
|
||||
foundMixedResults: "找到 {count} 个结果({docCount} 篇文档,{webCount} 条网页)",
|
||||
webResults: "找到 {count} 条网页",
|
||||
grepSummary: "找到 {chunks} 个匹配片段,来自 {docs} 个文档",
|
||||
},
|
||||
grepResults: {
|
||||
@@ -5165,6 +5167,10 @@ export default {
|
||||
understandDone: "已完成问题理解",
|
||||
searching: "正在检索知识库...",
|
||||
searchingWithQuery: "正在检索知识库:「{query}」",
|
||||
searchingWeb: "正在检索网络...",
|
||||
searchingWebWithQuery: "正在检索网络:「{query}」",
|
||||
searchingMixed: "正在检索知识库和网络...",
|
||||
searchingMixedWithQuery: "正在检索知识库和网络:「{query}」",
|
||||
searchDone: "检索完成",
|
||||
searchDoneWithQuery: "检索知识库:「{query}」",
|
||||
referencedDocs: "引用 <strong>{count}</strong> 篇文档",
|
||||
@@ -5175,6 +5181,8 @@ export default {
|
||||
calling: "正在调用 {name}...",
|
||||
searchKb: "检索知识库",
|
||||
searchKbFailed: "检索知识库失败",
|
||||
searchMixed: "检索知识库和网络",
|
||||
searchMixedFailed: "检索失败",
|
||||
webSearch: "网络搜索",
|
||||
webSearchFailed: "网络搜索失败",
|
||||
grepSearch: "搜索关键词",
|
||||
|
||||
@@ -66,3 +66,13 @@ test('getRagPipelineStepTitle uses query-aware search labels', () => {
|
||||
})
|
||||
assert.equal(title, 'searching 讯飞开放平台')
|
||||
})
|
||||
|
||||
test('getRagPipelineStepTitle uses web labels when search_source is web', () => {
|
||||
const title = getRagPipelineStepTitle(t, {
|
||||
tool_name: 'knowledge_search',
|
||||
pending: false,
|
||||
success: true,
|
||||
arguments: { search_source: 'web' },
|
||||
})
|
||||
assert.equal(title, 'agentStream.toolStatus.webSearch')
|
||||
})
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { ComposerTranslation } from 'vue-i18n'
|
||||
|
||||
export type RetrievalSearchSource = 'knowledge' | 'web' | 'mixed'
|
||||
|
||||
function collectQueryStrings(value: unknown): string[] {
|
||||
if (value == null) return []
|
||||
|
||||
@@ -71,6 +73,44 @@ export function getWikiPageText(args: unknown): string {
|
||||
return Array.from(new Set(slugs)).join('、')
|
||||
}
|
||||
|
||||
export function getRetrievalSearchSource(
|
||||
args: unknown,
|
||||
toolData?: Record<string, unknown> | null,
|
||||
): RetrievalSearchSource {
|
||||
const fromArgs =
|
||||
args && typeof args === 'object'
|
||||
? String((args as Record<string, unknown>).search_source || '')
|
||||
: ''
|
||||
const fromData = toolData ? String(toolData.search_source || '') : ''
|
||||
const source = (fromData || fromArgs).trim()
|
||||
if (source === 'web' || source === 'mixed') {
|
||||
return source
|
||||
}
|
||||
return 'knowledge'
|
||||
}
|
||||
|
||||
function getRetrievalStatusKeys(source: RetrievalSearchSource, failed: boolean) {
|
||||
if (source === 'web') {
|
||||
return failed
|
||||
? { pending: 'agentStream.ragPipeline.searchingWeb', pendingWithQuery: 'agentStream.ragPipeline.searchingWebWithQuery', done: 'agentStream.toolStatus.webSearch', doneFailed: 'agentStream.toolStatus.webSearchFailed' }
|
||||
: { pending: 'agentStream.ragPipeline.searchingWeb', pendingWithQuery: 'agentStream.ragPipeline.searchingWebWithQuery', done: 'agentStream.toolStatus.webSearch', doneFailed: 'agentStream.toolStatus.webSearchFailed' }
|
||||
}
|
||||
if (source === 'mixed') {
|
||||
return {
|
||||
pending: 'agentStream.ragPipeline.searchingMixed',
|
||||
pendingWithQuery: 'agentStream.ragPipeline.searchingMixedWithQuery',
|
||||
done: 'agentStream.toolStatus.searchMixed',
|
||||
doneFailed: 'agentStream.toolStatus.searchMixedFailed',
|
||||
}
|
||||
}
|
||||
return {
|
||||
pending: 'agentStream.ragPipeline.searching',
|
||||
pendingWithQuery: 'agentStream.ragPipeline.searchingWithQuery',
|
||||
done: 'agentStream.toolStatus.searchKb',
|
||||
doneFailed: 'agentStream.toolStatus.searchKbFailed',
|
||||
}
|
||||
}
|
||||
|
||||
export function getKnowledgeSearchSummaryHtml(
|
||||
t: ComposerTranslation,
|
||||
toolData: Record<string, unknown> | null | undefined,
|
||||
@@ -81,6 +121,14 @@ export function getKnowledgeSearchSummaryHtml(
|
||||
const count = (Array.isArray(results) ? results.length : 0) || Number(toolData.count) || 0
|
||||
if (count === 0) return t('agentStream.search.noResults')
|
||||
|
||||
const searchSource = getRetrievalSearchSource(null, toolData)
|
||||
const webCount = Number(toolData.web_count) || 0
|
||||
const docCount = Number(toolData.doc_count) || 0
|
||||
|
||||
if (searchSource === 'web' || (webCount > 0 && docCount === 0)) {
|
||||
return t('agentStream.search.webResults', { count: `<strong>${count}</strong>` })
|
||||
}
|
||||
|
||||
const kbCounts = toolData.kb_counts
|
||||
const kbCount = kbCounts && typeof kbCounts === 'object' ? Object.keys(kbCounts).length : 0
|
||||
if (kbCount > 0) {
|
||||
@@ -90,6 +138,14 @@ export function getKnowledgeSearchSummaryHtml(
|
||||
})
|
||||
}
|
||||
|
||||
if (searchSource === 'mixed' && docCount > 0 && webCount > 0) {
|
||||
return t('agentStream.search.foundMixedResults', {
|
||||
count: `<strong>${count}</strong>`,
|
||||
docCount: `<strong>${docCount}</strong>`,
|
||||
webCount: `<strong>${webCount}</strong>`,
|
||||
})
|
||||
}
|
||||
|
||||
return t('agentStream.search.foundResults', { count: `<strong>${count}</strong>` })
|
||||
}
|
||||
|
||||
@@ -115,15 +171,15 @@ export function getRagPipelineStepTitle(t: ComposerTranslation, event: RagPipeli
|
||||
}
|
||||
|
||||
if (toolName === 'knowledge_search' || toolName === 'search_knowledge') {
|
||||
const searchSource = getRetrievalSearchSource(event.arguments, event.tool_data)
|
||||
const labels = getRetrievalStatusKeys(searchSource, event.success === false)
|
||||
if (pending) {
|
||||
return query
|
||||
? t('agentStream.ragPipeline.searchingWithQuery', { query })
|
||||
: t('agentStream.ragPipeline.searching')
|
||||
? t(labels.pendingWithQuery, { query })
|
||||
: t(labels.pending)
|
||||
}
|
||||
|
||||
const baseTitle = event.success === false
|
||||
? t('agentStream.toolStatus.searchKbFailed')
|
||||
: t('agentStream.toolStatus.searchKb')
|
||||
const baseTitle = event.success === false ? t(labels.doneFailed) : t(labels.done)
|
||||
return query ? `${baseTitle}:「${query}」` : baseTitle
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
/** TDesign icon names for agent / RAG pipeline tool steps. */
|
||||
export function getAgentToolIconName(toolName: string): string {
|
||||
export function getAgentToolIconName(
|
||||
toolName: string,
|
||||
searchSource?: 'knowledge' | 'web' | 'mixed',
|
||||
): string {
|
||||
if (toolName === 'thinking') {
|
||||
return 'ai-search'
|
||||
}
|
||||
if (toolName === 'search_knowledge' || toolName === 'knowledge_search') {
|
||||
if (searchSource === 'web') {
|
||||
return 'internet'
|
||||
}
|
||||
return 'data-search'
|
||||
}
|
||||
if (toolName === 'wiki_search') {
|
||||
|
||||
@@ -19,6 +19,20 @@ test('synthesizeRagPipelineToolEvents builds completed retrieval steps', () => {
|
||||
assert.equal(events[0].tool_name, 'query_understand')
|
||||
assert.equal(events[1].tool_name, 'knowledge_search')
|
||||
assert.equal(events[1].tool_data.count, 3)
|
||||
assert.equal(events[1].tool_data.search_source, 'knowledge')
|
||||
})
|
||||
|
||||
test('synthesizeRagPipelineToolEvents marks web-only references as web search', () => {
|
||||
const events = synthesizeRagPipelineToolEvents({
|
||||
knowledge_references: [
|
||||
{ chunk_type: 'web_search', knowledge_title: 'page-1' },
|
||||
{ chunk_type: 'web_search', knowledge_title: 'page-2' },
|
||||
],
|
||||
})
|
||||
|
||||
assert.equal(events[1].tool_data.search_source, 'web')
|
||||
assert.equal(events[1].tool_data.web_count, 2)
|
||||
assert.equal(events[1].tool_data.doc_count, 0)
|
||||
})
|
||||
|
||||
test('ensureRagPipelineHistoryStream restores quick-answer history after reload', () => {
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
export const RAG_PIPELINE_TOOL_NAMES = new Set(['query_understand', 'knowledge_search'])
|
||||
|
||||
type RagHistoryReference = {
|
||||
chunk_type?: string
|
||||
knowledge_id?: string
|
||||
knowledge_title?: string
|
||||
}
|
||||
|
||||
function inferRetrievalSearchSource(refs: RagHistoryReference[]): 'knowledge' | 'web' | 'mixed' {
|
||||
let docCount = 0
|
||||
let webCount = 0
|
||||
for (const ref of refs) {
|
||||
if (ref.chunk_type === 'web_search') {
|
||||
webCount++
|
||||
} else {
|
||||
docCount++
|
||||
}
|
||||
}
|
||||
if (docCount > 0 && webCount > 0) return 'mixed'
|
||||
if (webCount > 0) return 'web'
|
||||
return 'knowledge'
|
||||
}
|
||||
|
||||
type RagHistoryMessage = {
|
||||
knowledge_references?: Array<{
|
||||
chunk_type?: string
|
||||
knowledge_id?: string
|
||||
knowledge_title?: string
|
||||
}>
|
||||
knowledge_references?: RagHistoryReference[]
|
||||
agentEventStream?: Array<Record<string, unknown>>
|
||||
}
|
||||
|
||||
@@ -25,13 +42,21 @@ export function synthesizeRagPipelineToolEvents(
|
||||
): Array<Record<string, unknown>> {
|
||||
const refs = item.knowledge_references ?? []
|
||||
const kbCounts: Record<string, number> = {}
|
||||
let docCount = 0
|
||||
let webCount = 0
|
||||
|
||||
for (const ref of refs) {
|
||||
if (ref.chunk_type === 'web_search') continue
|
||||
if (ref.chunk_type === 'web_search') {
|
||||
webCount++
|
||||
continue
|
||||
}
|
||||
docCount++
|
||||
const key = ref.knowledge_id || ref.knowledge_title || 'document'
|
||||
kbCounts[key] = (kbCounts[key] || 0) + 1
|
||||
}
|
||||
|
||||
const searchSource = inferRetrievalSearchSource(refs)
|
||||
|
||||
const events: Array<Record<string, unknown>> = [
|
||||
{
|
||||
type: 'tool_call',
|
||||
@@ -46,8 +71,12 @@ export function synthesizeRagPipelineToolEvents(
|
||||
tool_name: 'knowledge_search',
|
||||
pending: false,
|
||||
success: true,
|
||||
arguments: { search_source: searchSource },
|
||||
tool_data: {
|
||||
count: refs.length,
|
||||
doc_count: docCount,
|
||||
web_count: webCount,
|
||||
search_source: searchSource,
|
||||
kb_counts: kbCounts,
|
||||
results: refs,
|
||||
},
|
||||
|
||||
@@ -212,6 +212,7 @@ import { getAgentToolIconName } from '@/utils/agent-tool-icons'
|
||||
import {
|
||||
getKnowledgeSearchSummaryHtml,
|
||||
getRagPipelineStepTitle,
|
||||
getRetrievalSearchSource,
|
||||
} from '@/utils/agent-tool-display'
|
||||
import { RAG_PIPELINE_TOOL_NAMES } from '@/utils/rag-pipeline-history'
|
||||
|
||||
@@ -286,6 +287,9 @@ const steps = computed(() => {
|
||||
: null
|
||||
|
||||
const isSearchTool = toolName === 'knowledge_search' || toolName === 'search_knowledge'
|
||||
const searchSource = isSearchTool
|
||||
? getRetrievalSearchSource(event.arguments, toolData)
|
||||
: undefined
|
||||
const summaryHtml =
|
||||
!pending && isSearchTool && toolData
|
||||
? getKnowledgeSearchSummaryHtml(t, toolData)
|
||||
@@ -294,7 +298,7 @@ const steps = computed(() => {
|
||||
return {
|
||||
id: String(event.tool_call_id || `${toolName}-${event.timestamp || 0}`),
|
||||
pending,
|
||||
iconName: getAgentToolIconName(toolName),
|
||||
iconName: getAgentToolIconName(toolName, searchSource),
|
||||
title: getRagPipelineStepTitle(t, {
|
||||
tool_name: toolName,
|
||||
pending,
|
||||
@@ -386,6 +390,9 @@ const referencesHeaderText = computed(() => {
|
||||
if (docCount > 0) {
|
||||
return t('chat.referencesDocCount', { count: docCount })
|
||||
}
|
||||
if (webCount > 0) {
|
||||
return t('chat.referencesWebCount', { count: webCount })
|
||||
}
|
||||
return t('chat.referencesTitle', { count: total })
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user