Crate openai_schemars

Crate openai_schemars 

Source
Expand description

A Rust utility to generate JSON Schemas compatible with OpenAI’s function calling API, using schemars and serde_json.

§Example

use openai_schemars::{Schema, schemars};
use schemars::JsonSchema;

#[derive(JsonSchema)]
struct MyStruct {
    /// The name of the user
    name: String,
}

let schema = Schema::new::<MyStruct>().expect("Failed to generate schema");
println!("{}", serde_json::to_string_pretty(&schema.value).expect("Failed to serialize schema"));

Re-exports§

pub use schemars;

Structs§

Schema
A JSON Schema that is compatible with OpenAI’s function calling API.