File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
web/src/app/api/v1/token-count Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,10 @@ function convertContentToAnthropic(
220220
221221 for ( const part of content ) {
222222 if ( part . type === 'text' ) {
223- anthropicContent . push ( { type : 'text' , text : part . text . trim ( ) } )
223+ const text = part . text . trim ( )
224+ if ( text ) {
225+ anthropicContent . push ( { type : 'text' , text } )
226+ }
224227 } else if ( part . type === 'tool-call' && role === 'assistant' ) {
225228 anthropicContent . push ( {
226229 type : 'tool_use' ,
@@ -238,13 +241,16 @@ function convertContentToAnthropic(
238241 } ,
239242 } )
240243 } else if ( part . type === 'json' ) {
241- anthropicContent . push ( {
242- type : 'text' ,
243- text :
244- typeof part . value === 'string'
245- ? part . value . trim ( )
246- : JSON . stringify ( part . value ) . trim ( ) ,
247- } )
244+ const text =
245+ typeof part . value === 'string'
246+ ? part . value . trim ( )
247+ : JSON . stringify ( part . value ) . trim ( )
248+ if ( text ) {
249+ anthropicContent . push ( {
250+ type : 'text' ,
251+ text,
252+ } )
253+ }
248254 }
249255 }
250256
You can’t perform that action at this time.
0 commit comments