pub trait StructuredOutput: for<'de> Deserialize<'de> + JsonSchema {
// Provided methods
fn type_name() -> &'static str { ... }
fn model_validate_json_value(value: &Value) -> Result<Self, Error> { ... }
fn model_validate_json_str(value: &str) -> Result<Self, Error> { ... }
fn get_structured_output_schema() -> Value { ... }
}Expand description
A trait for structured output types that can be used with potatohead prompts agents and workflows.
§Example
use potatohead_macro::StructureOutput;
use serde::{Serialize, Deserialize};
use schemars::JsonSchema;
#[derive(Serialize, Deserialize, JsonSchema)]
struct MyOutput {
message: String,
value: i32,
}
impl StructuredOutput for MyOutput {}
let schema = MyOutput::get_structured_output_schema();Provided Methods§
fn type_name() -> &'static str
Sourcefn model_validate_json_value(value: &Value) -> Result<Self, Error>
fn model_validate_json_value(value: &Value) -> Result<Self, Error>
fn model_validate_json_str(value: &str) -> Result<Self, Error>
Sourcefn get_structured_output_schema() -> Value
fn get_structured_output_schema() -> Value
Generates an OpenAI-compatible JSON schema.
§Returns
Value- The JSON schema wrapped in OpenAI’s format
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".