mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-06 21:35:52 +08:00
Update transform.ts
This commit is contained in:
parent
335bf47dbd
commit
634c478e18
@ -21,7 +21,7 @@ type contentBlock =
|
|||||||
type: 'tool-call'
|
type: 'tool-call'
|
||||||
toolCallId: string
|
toolCallId: string
|
||||||
toolName: string
|
toolName: string
|
||||||
input?: string
|
input: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentBlockState = new Map<string, contentBlock>()
|
const contentBlockState = new Map<string, contentBlock>()
|
||||||
@ -122,18 +122,20 @@ function handleUserOrAssistantMessage(message: Extract<SDKMessage, { type: 'assi
|
|||||||
contentBlockState.set(block.id, {
|
contentBlockState.set(block.id, {
|
||||||
type: 'tool-call',
|
type: 'tool-call',
|
||||||
toolCallId: block.id,
|
toolCallId: block.id,
|
||||||
toolName: block.name
|
toolName: block.name,
|
||||||
|
input: block.input
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'tool_result': {
|
case 'tool_result': {
|
||||||
logger.debug('Handling tool result:', { block })
|
logger.debug('Handling tool result:', { block })
|
||||||
logger.debug('contentblockState', { content: contentBlockState })
|
logger.debug('contentblockState', { content: contentBlockState })
|
||||||
|
const hasToolCall = contentBlockState.has(block.tool_use_id)
|
||||||
const toolCall = contentBlockState.get(block.tool_use_id) as toolCallBlock
|
const toolCall = contentBlockState.get(block.tool_use_id) as toolCallBlock
|
||||||
chunks.push({
|
chunks.push({
|
||||||
type: 'tool-result',
|
type: 'tool-result',
|
||||||
toolCallId: block.tool_use_id,
|
toolCallId: block.tool_use_id,
|
||||||
toolName: contentBlockState.has(block.tool_use_id) ? toolCall.toolName : 'Unknown',
|
toolName: hasToolCall ? toolCall.toolName : 'Unknown',
|
||||||
input: '',
|
input: hasToolCall ? toolCall.input : '',
|
||||||
output: block.content
|
output: block.content
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user