Skip to content

Commit 3c124a5

Browse files
committed
fix(oci): uppercase tool type field for OCI V2 API compatibility
OCI Generative AI expects tool type as "FUNCTION" (uppercase) but the SDK passes through the Cohere format "function" (lowercase), causing a 400 error. Transform tool types to uppercase like we do for message roles and content types.
1 parent 2598c9a commit 3c124a5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/cohere/oci_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,13 @@ def transform_request_to_oci(
756756
if "stop_sequences" in cohere_body:
757757
chat_request["stopSequences"] = cohere_body["stop_sequences"]
758758
if "tools" in cohere_body:
759-
chat_request["tools"] = cohere_body["tools"]
759+
oci_tools = []
760+
for tool in cohere_body["tools"]:
761+
oci_tool = {**tool}
762+
if "type" in oci_tool:
763+
oci_tool["type"] = oci_tool["type"].upper()
764+
oci_tools.append(oci_tool)
765+
chat_request["tools"] = oci_tools
760766
if "strict_tools" in cohere_body:
761767
chat_request["strictTools"] = cohere_body["strict_tools"]
762768
if "documents" in cohere_body:

0 commit comments

Comments
 (0)