pub struct JsonSpec {
pub name: String,
pub description: Option<String>,
pub schema: Value,
}Expand description
JSON specification used to enforce structured output.
Fields§
§name: StringSpecification name (primarily used by OpenAI).
IMPORTANT: For OpenAI, only - and _ are allowed; no spaces or other special characters.
description: Option<String>Human-readable description (used by some adapters in the future). NOTE: Currently ignored by the OpenAI adapter.
schema: ValueSimplified JSON schema forwarded to the provider.
Implementations§
Source§impl JsonSpec
Setters
impl JsonSpec
Setters
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set an optional description (builder-style).
Source§impl JsonSpec
Helpers
impl JsonSpec
Helpers
Sourcepub fn schema_with_additional_properties_false(&self) -> Value
pub fn schema_with_additional_properties_false(&self) -> Value
Returns a clone of the schema with "additionalProperties": false injected into every
object node. Required by several providers (Anthropic, OpenAI) whose structured-output
APIs reject schemas that omit this constraint.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JsonSpec
impl<'de> Deserialize<'de> for JsonSpec
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
Source§impl From<JsonSpec> for ChatResponseFormat
impl From<JsonSpec> for ChatResponseFormat
Auto Trait Implementations§
impl Freeze for JsonSpec
impl RefUnwindSafe for JsonSpec
impl Send for JsonSpec
impl Sync for JsonSpec
impl Unpin for JsonSpec
impl UnsafeUnpin for JsonSpec
impl UnwindSafe for JsonSpec
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