@@ -127,13 +127,16 @@ describe("Anthropic to OpenAI translation logic", () => {
127127
128128 test ( "should handle thinking blocks in assistant messages" , ( ) => {
129129 const anthropicPayload : AnthropicMessagesPayload = {
130- model : "gpt-4o " ,
130+ model : "claude-3-5-sonnet-20241022 " ,
131131 messages : [
132132 { role : "user" , content : "What is 2+2?" } ,
133133 {
134134 role : "assistant" ,
135135 content : [
136- { type : "thinking" , thinking : "Let me think about this simple math problem..." } ,
136+ {
137+ type : "thinking" ,
138+ thinking : "Let me think about this simple math problem..." ,
139+ } ,
137140 { type : "text" , text : "2+2 equals 4." } ,
138141 ] ,
139142 } ,
@@ -142,36 +145,55 @@ describe("Anthropic to OpenAI translation logic", () => {
142145 }
143146 const openAIPayload = translateToOpenAI ( anthropicPayload )
144147 expect ( isValidChatCompletionRequest ( openAIPayload ) ) . toBe ( true )
145-
148+
146149 // Check that thinking content is combined with text content
147- const assistantMessage = openAIPayload . messages . find ( m => m . role === "assistant" )
148- expect ( assistantMessage ?. content ) . toContain ( "Let me think about this simple math problem..." )
150+ const assistantMessage = openAIPayload . messages . find (
151+ ( m ) => m . role === "assistant" ,
152+ )
153+ expect ( assistantMessage ?. content ) . toContain (
154+ "Let me think about this simple math problem..." ,
155+ )
149156 expect ( assistantMessage ?. content ) . toContain ( "2+2 equals 4." )
150157 } )
151158
152159 test ( "should handle thinking blocks with tool calls" , ( ) => {
153160 const anthropicPayload : AnthropicMessagesPayload = {
154- model : "gpt-4o " ,
161+ model : "claude-3-5-sonnet-20241022 " ,
155162 messages : [
156163 { role : "user" , content : "What's the weather?" } ,
157164 {
158165 role : "assistant" ,
159166 content : [
160- { type : "thinking" , thinking : "I need to call the weather API to get current weather information." } ,
167+ {
168+ type : "thinking" ,
169+ thinking :
170+ "I need to call the weather API to get current weather information." ,
171+ } ,
161172 { type : "text" , text : "I'll check the weather for you." } ,
162- { type : "tool_use" , id : "call_123" , name : "get_weather" , input : { location : "New York" } } ,
173+ {
174+ type : "tool_use" ,
175+ id : "call_123" ,
176+ name : "get_weather" ,
177+ input : { location : "New York" } ,
178+ } ,
163179 ] ,
164180 } ,
165181 ] ,
166182 max_tokens : 100 ,
167183 }
168184 const openAIPayload = translateToOpenAI ( anthropicPayload )
169185 expect ( isValidChatCompletionRequest ( openAIPayload ) ) . toBe ( true )
170-
186+
171187 // Check that thinking content is included in the message content
172- const assistantMessage = openAIPayload . messages . find ( m => m . role === "assistant" )
173- expect ( assistantMessage ?. content ) . toContain ( "I need to call the weather API" )
174- expect ( assistantMessage ?. content ) . toContain ( "I'll check the weather for you." )
188+ const assistantMessage = openAIPayload . messages . find (
189+ ( m ) => m . role === "assistant" ,
190+ )
191+ expect ( assistantMessage ?. content ) . toContain (
192+ "I need to call the weather API" ,
193+ )
194+ expect ( assistantMessage ?. content ) . toContain (
195+ "I'll check the weather for you." ,
196+ )
175197 expect ( assistantMessage ?. tool_calls ) . toHaveLength ( 1 )
176198 expect ( assistantMessage ?. tool_calls ?. [ 0 ] . function . name ) . toBe ( "get_weather" )
177199 } )
0 commit comments