llm-schema

Crates.iollm-schema
lib.rsllm-schema
version0.1.0
created_at2025-07-08 07:41:56.228598+00
updated_at2025-07-08 07:41:56.228598+00
descriptionA Rust library for type-safe schema conversion between Rust types and LLM.
homepage
repositoryhttps://github.com/zTgx/llm-schema
max_upload_size
id1742170
size13,369
(zTgx)

documentation

https://docs.rs/llm-schema

README

llm-schema

For type-safe schema conversion between Rust types and LLM.

Version Downloads License Documentation

Note: This project is under active development and APIs may change.

Quick start

use llm_schema::LlmSchema;

#[derive(LlmSchema)]
struct Example {
    name: String,
    age: i32,
    #[llmschem(require)]
    email: String,
    nickname: Option<String>,
}

fn main() {
    let schema = Example::llm_schema();
    println!("{}", serde_json::to_string_pretty(&schema).unwrap());

    // {
    //     "properties": {
    //         "age": {
    //         "type": "number"
    //         },
    //         "email": {
    //         "type": "string"
    //         },
    //         "name": {
    //         "type": "string"
    //         },
    //         "nickname": {
    //         "type": "null"
    //         }
    //     },
    //     "required": [
    //         "email"
    //     ],
    //     "type": "object"
    // }
}

Star History

Star History Chart

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 0

cargo fmt