mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 13:31:32 +08:00
fix: update MessageKnowledgeSearch to use knowledgeReferences
- Modified MessageKnowledgeSearch component to display additional context from toolInput. - Updated the fetch complete message to reflect the count of knowledgeReferences instead of toolOutput. - Adjusted the mapping of results to iterate over knowledgeReferences for rendering.
This commit is contained in:
parent
cb55f7a69b
commit
3630133efd
@ -16,14 +16,14 @@ export function MessageKnowledgeSearchToolTitle({ toolResponse }: { toolResponse
|
||||
text={
|
||||
<PrepareToolWrapper>
|
||||
{i18n.t('message.searching')}
|
||||
<span>{toolInput?.rewrite ?? toolInput?.query ?? ''}</span>
|
||||
<span>{toolInput?.additionalContext ?? ''}</span>
|
||||
</PrepareToolWrapper>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<MessageWebSearchToolTitleTextWrapper type="secondary">
|
||||
<FileSearch size={16} style={{ color: 'unset' }} />
|
||||
{i18n.t('message.websearch.fetch_complete', { count: toolOutput.length ?? 0 })}
|
||||
{i18n.t('message.websearch.fetch_complete', { count: toolOutput.knowledgeReferences.length ?? 0 })}
|
||||
</MessageWebSearchToolTitleTextWrapper>
|
||||
)
|
||||
}
|
||||
@ -33,7 +33,7 @@ export function MessageKnowledgeSearchToolBody({ toolResponse }: { toolResponse:
|
||||
|
||||
return toolResponse.status === 'done' ? (
|
||||
<MessageWebSearchToolBodyUlWrapper>
|
||||
{toolOutput.map((result) => (
|
||||
{toolOutput.knowledgeReferences.map((result) => (
|
||||
<li key={result.id}>
|
||||
<span>{result.id}</span>
|
||||
<span>{result.content}</span>
|
||||
|
||||
@ -114,6 +114,18 @@ export const createToolCallbacks = (deps: ToolCallbacksDependencies) => {
|
||||
citationBlockId = citationBlock.id
|
||||
blockManager.handleBlockTransition(citationBlock, MessageBlockType.CITATION)
|
||||
}
|
||||
if (toolResponse.tool.name === 'builtin_knowledge_search' && toolResponse.response?.knowledgeReferences) {
|
||||
const citationBlock = createCitationBlock(
|
||||
assistantMsgId,
|
||||
{ knowledge: toolResponse.response.knowledgeReferences },
|
||||
{
|
||||
status: MessageBlockStatus.SUCCESS
|
||||
}
|
||||
)
|
||||
citationBlockId = citationBlock.id
|
||||
blockManager.handleBlockTransition(citationBlock, MessageBlockType.CITATION)
|
||||
}
|
||||
// TODO: 处理 memory 引用
|
||||
} else {
|
||||
logger.warn(
|
||||
`[onToolCallComplete] Received unhandled tool status: ${toolResponse.status} for ID: ${toolResponse.id}`
|
||||
|
||||
@ -135,7 +135,7 @@ export function createThinkingBlock(
|
||||
return {
|
||||
...baseBlock,
|
||||
content,
|
||||
thinking_millsec: overrides.thinking_millsec
|
||||
thinking_millsec: overrides.thinking_millsec || 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user