mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +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={
|
text={
|
||||||
<PrepareToolWrapper>
|
<PrepareToolWrapper>
|
||||||
{i18n.t('message.searching')}
|
{i18n.t('message.searching')}
|
||||||
<span>{toolInput?.rewrite ?? toolInput?.query ?? ''}</span>
|
<span>{toolInput?.additionalContext ?? ''}</span>
|
||||||
</PrepareToolWrapper>
|
</PrepareToolWrapper>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<MessageWebSearchToolTitleTextWrapper type="secondary">
|
<MessageWebSearchToolTitleTextWrapper type="secondary">
|
||||||
<FileSearch size={16} style={{ color: 'unset' }} />
|
<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>
|
</MessageWebSearchToolTitleTextWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ export function MessageKnowledgeSearchToolBody({ toolResponse }: { toolResponse:
|
|||||||
|
|
||||||
return toolResponse.status === 'done' ? (
|
return toolResponse.status === 'done' ? (
|
||||||
<MessageWebSearchToolBodyUlWrapper>
|
<MessageWebSearchToolBodyUlWrapper>
|
||||||
{toolOutput.map((result) => (
|
{toolOutput.knowledgeReferences.map((result) => (
|
||||||
<li key={result.id}>
|
<li key={result.id}>
|
||||||
<span>{result.id}</span>
|
<span>{result.id}</span>
|
||||||
<span>{result.content}</span>
|
<span>{result.content}</span>
|
||||||
|
|||||||
@ -114,6 +114,18 @@ export const createToolCallbacks = (deps: ToolCallbacksDependencies) => {
|
|||||||
citationBlockId = citationBlock.id
|
citationBlockId = citationBlock.id
|
||||||
blockManager.handleBlockTransition(citationBlock, MessageBlockType.CITATION)
|
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 {
|
} else {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`[onToolCallComplete] Received unhandled tool status: ${toolResponse.status} for ID: ${toolResponse.id}`
|
`[onToolCallComplete] Received unhandled tool status: ${toolResponse.status} for ID: ${toolResponse.id}`
|
||||||
|
|||||||
@ -135,7 +135,7 @@ export function createThinkingBlock(
|
|||||||
return {
|
return {
|
||||||
...baseBlock,
|
...baseBlock,
|
||||||
content,
|
content,
|
||||||
thinking_millsec: overrides.thinking_millsec
|
thinking_millsec: overrides.thinking_millsec || 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user