Adds structured output to chat

This commit is contained in:
2026-01-07 16:33:18 +00:00
parent 69a9ce0de5
commit a9ab4e6d60
2 changed files with 50 additions and 0 deletions

View File

@@ -63,6 +63,9 @@ pub struct ChatRequest {
#[serde(skip_serializing_if = "Vec::is_empty")]
pub tools: Vec<Tool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<Value>,
}
impl ChatRequest {
@@ -92,6 +95,7 @@ impl ChatRequestBuilder {
stream: None,
options: None,
tools: vec![],
format: None,
},
}
}
@@ -116,6 +120,11 @@ impl ChatRequestBuilder {
self
}
pub fn format(mut self, json_schema: Value) -> Self {
self.chat_request.format = Some(json_schema);
self
}
pub fn build(self) -> ChatRequest {
self.chat_request
}