@@ -39,9 +39,9 @@ class Anthropic extends BaseLLM {
39
39
} ) ) ,
40
40
tool_choice : options . toolChoice
41
41
? {
42
- type : "tool" ,
43
- name : options . toolChoice . function . name ,
44
- }
42
+ type : "tool" ,
43
+ name : options . toolChoice . function . name ,
44
+ }
45
45
: undefined ,
46
46
thinking : options . thinking ,
47
47
} ;
@@ -133,28 +133,16 @@ class Anthropic extends BaseLLM {
133
133
return chatMessage ;
134
134
}
135
135
136
- // Filter out empty thinking blocks before mapping
137
- const filteredContent = Array . isArray ( message . content )
138
- ? message . content . filter (
139
- ( part ) =>
140
- ! (
141
- part . type === "thinking" &&
142
- ( ! part . thinking || part . thinking . trim ( ) === "" ) &&
143
- ( ! part . signature || part . signature . trim ( ) === "" )
144
- ) ,
145
- )
146
- : message . content ;
147
-
148
136
const convertedContent = (
149
- Array . isArray ( filteredContent ) ? filteredContent : [ filteredContent ]
137
+ Array . isArray ( message . content ) ? message . content : [ message . content ]
150
138
) . map ( ( part , contentIdx ) => {
151
139
if ( part . type === "text" ) {
152
140
const newpart = {
153
141
...part ,
154
142
// If multiple text parts, only add cache_control to the last one
155
143
...( addCaching &&
156
- contentIdx ==
157
- ( Array . isArray ( filteredContent ) ? filteredContent . length : 1 ) - 1
144
+ contentIdx ==
145
+ ( Array . isArray ( message . content ) ? message . content . length : 1 ) - 1
158
146
? { cache_control : { type : "ephemeral" } }
159
147
: { } ) ,
160
148
} ;
@@ -270,12 +258,12 @@ class Anthropic extends BaseLLM {
270
258
messages : msgs ,
271
259
system : shouldCacheSystemMessage
272
260
? [
273
- {
274
- type : "text" ,
275
- text : this . systemMessage ,
276
- cache_control : { type : "ephemeral" } ,
277
- } ,
278
- ]
261
+ {
262
+ type : "text" ,
263
+ text : this . systemMessage ,
264
+ cache_control : { type : "ephemeral" } ,
265
+ } ,
266
+ ]
279
267
: systemMessage ,
280
268
} ;
281
269
0 commit comments