File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,14 @@ function mapContent(
166166 return null
167167 }
168168
169+ const hasImage = content . some ( ( block ) => block . type === "image" )
170+ if ( ! hasImage ) {
171+ return content
172+ . filter ( ( block ) : block is AnthropicTextBlock => block . type === "text" )
173+ . map ( ( block ) => block . text )
174+ . join ( "\n\n" )
175+ }
176+
169177 const contentParts : Array < ContentPart > = [ ]
170178 for ( const block of content ) {
171179 if ( block . type === "text" ) {
@@ -248,8 +256,8 @@ export function translateToAnthropic(
248256 stop_reason : mapOpenAIStopReasonToAnthropic ( choice . finish_reason ) ,
249257 stop_sequence : null ,
250258 usage : {
251- input_tokens : 1 ,
252- output_tokens : 1 ,
259+ input_tokens : response . usage ?. prompt_tokens ?? 0 ,
260+ output_tokens : response . usage ?. completion_tokens ?? 0 ,
253261 } ,
254262 }
255263}
You can’t perform that action at this time.
0 commit comments