pub enum ResponseFormat {
Text,
JsonObject,
JsonSchema {
name: String,
description: Option<String>,
schema: Value,
strict: Option<bool>,
},
}Expand description
The requested structured-output format for a response.
Mirrors the Python ChatOptions.response_format / .NET ChatResponseFormat.
The serialized form matches the OpenAI response_format request object, so a
provider can map it with serde_json::to_value(&format):
ResponseFormat::Text→{"type":"text"}ResponseFormat::JsonObject→{"type":"json_object"}ResponseFormat::JsonSchema→{"type":"json_schema","json_schema":{"name":…,"schema":…}}
Variants§
Text
Free-form text (the default provider behavior).
JsonObject
A syntactically valid JSON object, without an enforced schema.
JsonSchema
A JSON object conforming to the given JSON Schema.
Implementations§
Source§impl ResponseFormat
impl ResponseFormat
Sourcepub fn json_schema(name: impl Into<String>, schema: Value) -> ResponseFormat
pub fn json_schema(name: impl Into<String>, schema: Value) -> ResponseFormat
Build a ResponseFormat::JsonSchema from a name and schema.
Trait Implementations§
Source§impl Clone for ResponseFormat
impl Clone for ResponseFormat
Source§fn clone(&self) -> ResponseFormat
fn clone(&self) -> ResponseFormat
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResponseFormat
impl Debug for ResponseFormat
Source§impl<'de> Deserialize<'de> for ResponseFormat
impl<'de> Deserialize<'de> for ResponseFormat
Source§fn deserialize<D>(
d: D,
) -> Result<ResponseFormat, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
d: D,
) -> Result<ResponseFormat, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ResponseFormat
impl PartialEq for ResponseFormat
Source§impl Serialize for ResponseFormat
impl Serialize for ResponseFormat
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for ResponseFormat
Auto Trait Implementations§
impl Freeze for ResponseFormat
impl RefUnwindSafe for ResponseFormat
impl Send for ResponseFormat
impl Sync for ResponseFormat
impl Unpin for ResponseFormat
impl UnsafeUnpin for ResponseFormat
impl UnwindSafe for ResponseFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more