pub enum ResponseFormat {
Text,
JsonObject,
JsonSchema {
json_schema: JsonSchema,
},
}Expand description
Response format configuration
Variants§
Text
Text response format (default)
JsonObject
JSON object response format
JsonSchema
JSON schema response format (Structured Outputs)
Fields
§
json_schema: JsonSchemaJSON schema configuration
Implementations§
Source§impl ResponseFormat
impl ResponseFormat
Sourcepub fn json_schema<T>() -> JsonSchemawhere
T: JsonSchema,
Available on crate feature schema only.
pub fn json_schema<T>() -> JsonSchemawhere
T: JsonSchema,
schema only.Creates a JSON schema from a type implementing schemars::JsonSchema.
Returns a JsonSchema that can be used directly or customized with builder methods.
To use with ResponseFormat, wrap in ResponseFormat::JsonSchema { json_schema: ... }.
§Example
ⓘ
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use portkey_sdk::model::ResponseFormat;
#[derive(Serialize, Deserialize, JsonSchema)]
struct MyResponse {
message: String,
count: i32,
}
let response_format = ResponseFormat::JsonSchema {
json_schema: ResponseFormat::json_schema::<MyResponse>()
.with_description("A custom response structure")
.with_strict(true),
};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 · 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>(__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 ResponseFormat
impl RefUnwindSafe for ResponseFormat
impl Send for ResponseFormat
impl Sync for ResponseFormat
impl Unpin 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