pub struct ChatCompletionResponseFormat {
pub type_name: String,
pub json_schema: Schema,
}
Expand description
Specifies the format that the model must output for chat completions.
This structure is used to configure structured outputs, particularly for JSON schema-based responses that ensure the model returns data in a specific format.
§Fields
type_name
- The type of response format (e.g., “json_schema”)json_schema
- The JSON schema definition for structured output
§Example
use openai_tools::chat::ChatCompletionResponseFormat;
use openai_tools::structured_output::Schema;
let mut schema = Schema::chat_json_schema("person".to_string());
schema.add_property("name".to_string(), "string".to_string(), Some("Person's name".to_string()));
schema.add_property("age".to_string(), "integer".to_string(), Some("Person's age".to_string()));
let format = ChatCompletionResponseFormat::new("json_schema".to_string(), schema);
Fields§
§type_name: String
§json_schema: Schema
Implementations§
Source§impl ChatCompletionResponseFormat
impl ChatCompletionResponseFormat
Sourcepub fn new(type_name: String, json_schema: Schema) -> Self
pub fn new(type_name: String, json_schema: Schema) -> Self
Creates a new ChatCompletionResponseFormat
instance.
§Arguments
type_name
- The type of response format (typically “json_schema”)json_schema
- The JSON schema definition for structured output
§Returns
A new ChatCompletionResponseFormat
instance configured with the specified parameters.
§Example
use openai_tools::chat::ChatCompletionResponseFormat;
use openai_tools::structured_output::Schema;
let schema = Schema::chat_json_schema("example".to_string());
let format = ChatCompletionResponseFormat::new("json_schema".to_string(), schema);
Trait Implementations§
Source§impl Clone for ChatCompletionResponseFormat
impl Clone for ChatCompletionResponseFormat
Source§fn clone(&self) -> ChatCompletionResponseFormat
fn clone(&self) -> ChatCompletionResponseFormat
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ChatCompletionResponseFormat
impl Debug for ChatCompletionResponseFormat
Source§impl<'de> Deserialize<'de> for ChatCompletionResponseFormat
impl<'de> Deserialize<'de> for ChatCompletionResponseFormat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ChatCompletionResponseFormat
impl RefUnwindSafe for ChatCompletionResponseFormat
impl Send for ChatCompletionResponseFormat
impl Sync for ChatCompletionResponseFormat
impl Unpin for ChatCompletionResponseFormat
impl UnwindSafe for ChatCompletionResponseFormat
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more