diff --git a/src/backends/openai/responses/request/tests.rs b/src/backends/openai/responses/request/tests.rs index f90db9d..91b8a2a 100644 --- a/src/backends/openai/responses/request/tests.rs +++ b/src/backends/openai/responses/request/tests.rs @@ -38,6 +38,7 @@ fn sample_tool() -> Tool { description: "Get weather".to_string(), parameters: json!({"type": "object"}), }, + cache_control: None, } } diff --git a/src/providers/openai_compatible.rs b/src/providers/openai_compatible.rs index 5923bec..913d4df 100644 --- a/src/providers/openai_compatible.rs +++ b/src/providers/openai_compatible.rs @@ -208,6 +208,10 @@ pub struct OpenAIResponseFormat { pub response_type: OpenAIResponseType, #[serde(skip_serializing_if = "Option::is_none")] pub json_schema: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub schema: Option, } #[derive(Deserialize, Debug, Serialize)] @@ -260,10 +264,16 @@ pub struct StreamFunctionCall { impl From for OpenAIResponseFormat { fn from(structured_response_format: StructuredOutputFormat) -> Self { match structured_response_format.schema { - None => OpenAIResponseFormat { - response_type: OpenAIResponseType::JsonSchema, - json_schema: Some(structured_response_format), - }, + None => { + let name = structured_response_format.name.clone(); + let schema = structured_response_format.schema.clone(); + OpenAIResponseFormat { + response_type: OpenAIResponseType::JsonSchema, + json_schema: Some(structured_response_format), + schema: schema, + name: Some(name), + } + } Some(mut schema) => { schema = if schema.get("additionalProperties").is_none() { schema["additionalProperties"] = serde_json::json!(false); @@ -271,14 +281,17 @@ impl From for OpenAIResponseFormat { } else { schema }; + let name = structured_response_format.name; OpenAIResponseFormat { response_type: OpenAIResponseType::JsonSchema, + schema: Some(schema.clone()), json_schema: Some(StructuredOutputFormat { - name: structured_response_format.name, - description: structured_response_format.description, + name: name.clone(), schema: Some(schema), strict: structured_response_format.strict, + description: structured_response_format.description, }), + name: Some(name), } } } diff --git a/tests/test.rs b/tests/test.rs index 5992921..a10e5f7 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -278,6 +278,7 @@ mod bedrock_tests { }, "required": ["location"] }), + cache_control: None, }]; let messages = vec![ChatMessage::user("What's the weather in San Francisco?")]; @@ -330,6 +331,7 @@ mod bedrock_tests { }, "required": ["expression"] }), + cache_control: None, }]; // First request to get tool use @@ -664,6 +666,7 @@ mod bedrock_tests { name: "test_tool".to_string(), description: "A test tool".to_string(), input_schema: json!({"type": "object"}), + cache_control: None, }]; let messages = vec![ChatMessage::user("Use the tool")];