@ai-sdk/anthropic
Advanced tools
+1
-1
| { | ||
| "name": "@ai-sdk/anthropic", | ||
| "version": "4.0.0-beta.68", | ||
| "version": "4.0.0-beta.69", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -1212,3 +1212,6 @@ import { | ||
| messages.push({ role: 'assistant', content: anthropicContent }); | ||
| messages.push({ | ||
| role: 'assistant', | ||
| content: moveToolUseBlocksToEnd(anthropicContent), | ||
| }); | ||
@@ -1299,1 +1302,29 @@ break; | ||
| } | ||
| function moveToolUseBlocksToEnd( | ||
| content: AnthropicAssistantMessage['content'], | ||
| ): AnthropicAssistantMessage['content'] { | ||
| const result: AnthropicAssistantMessage['content'] = []; | ||
| let segment: AnthropicAssistantMessage['content'] = []; | ||
| function flushSegment() { | ||
| result.push( | ||
| ...segment.filter(part => part.type !== 'tool_use'), | ||
| ...segment.filter(part => part.type === 'tool_use'), | ||
| ); | ||
| segment = []; | ||
| } | ||
| for (const part of content) { | ||
| if (part.type === 'thinking' || part.type === 'redacted_thinking') { | ||
| flushSegment(); | ||
| result.push(part); | ||
| } else { | ||
| segment.push(part); | ||
| } | ||
| } | ||
| flushSegment(); | ||
| return result; | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1943763
0.22%24488
0.3%