@@ -513,11 +513,11 @@ def test_thinking_parameter_transformation(self):
513513
514514 result = transform_request_to_oci ("chat" , cohere_body , "compartment-123" )
515515
516- # Verify thinking parameter is transformed
516+ # Verify thinking parameter is transformed with camelCase for OCI API
517517 chat_request = result ["chatRequest" ]
518518 self .assertIn ("thinking" , chat_request )
519519 self .assertEqual (chat_request ["thinking" ]["type" ], "ENABLED" )
520- self .assertEqual (chat_request ["thinking" ]["token_budget " ], 10000 )
520+ self .assertEqual (chat_request ["thinking" ]["tokenBudget " ], 10000 ) # camelCase for OCI
521521
522522 def test_thinking_parameter_disabled (self ):
523523 """Test that disabled thinking is correctly transformed."""
@@ -656,6 +656,37 @@ def test_v2_response_finish_reason_uppercase(self):
656656 # V2 finish_reason should stay uppercase
657657 self .assertEqual (result ["finish_reason" ], "MAX_TOKENS" )
658658
659+ def test_v2_response_tool_calls_conversion (self ):
660+ """Test that V2 response converts toolCalls to tool_calls."""
661+ from cohere .oci_client import transform_oci_response_to_cohere
662+
663+ oci_response = {
664+ "chatResponse" : {
665+ "id" : "test-id" ,
666+ "message" : {
667+ "role" : "ASSISTANT" ,
668+ "content" : [{"type" : "TEXT" , "text" : "I'll help with that." }],
669+ "toolCalls" : [
670+ {
671+ "id" : "call_123" ,
672+ "type" : "function" ,
673+ "function" : {"name" : "get_weather" , "arguments" : '{"city": "London"}' },
674+ }
675+ ],
676+ },
677+ "finishReason" : "TOOL_CALL" ,
678+ "usage" : {"inputTokens" : 10 , "completionTokens" : 20 },
679+ }
680+ }
681+
682+ result = transform_oci_response_to_cohere ("chat" , oci_response , is_v2 = True )
683+
684+ # toolCalls should be converted to tool_calls
685+ self .assertIn ("tool_calls" , result ["message" ])
686+ self .assertNotIn ("toolCalls" , result ["message" ])
687+ self .assertEqual (len (result ["message" ]["tool_calls" ]), 1 )
688+ self .assertEqual (result ["message" ]["tool_calls" ][0 ]["id" ], "call_123" )
689+
659690
660691if __name__ == "__main__" :
661692 unittest .main ()
0 commit comments