#json-template #struct-generation #artificial-intelligence #derived #more-information #letting #ai-assisted

ai-json-template

Contains code we use for ai-assisted struct generation. Please also see the ai-json-template-derive crate for more information.

3 releases

Uses new Rust 2024

0.1.2 Jul 13, 2025
0.1.1 Mar 31, 2025
0.1.0 Mar 31, 2025

#1 in #more-information

Download history 142/week @ 2025-07-25 75/week @ 2025-08-01 125/week @ 2025-08-08 69/week @ 2025-08-15 241/week @ 2025-08-22 374/week @ 2025-08-29 371/week @ 2025-09-05 216/week @ 2025-09-12 223/week @ 2025-09-19 378/week @ 2025-09-26 172/week @ 2025-10-03 295/week @ 2025-10-10 363/week @ 2025-10-17 201/week @ 2025-10-24 289/week @ 2025-10-31 268/week @ 2025-11-07

1,195 downloads per month
Used in 114 crates (7 directly)

MIT license

105KB
2K SLoC

ai-json-template

contains the following code:

/// The derived code implements `AiJsonTemplate` for each struct, letting you
/// call `MyStruct::to_template()` to get a JSON “schema” describing how the
/// AI should produce data that matches this layout.
///
pub trait AiJsonTemplate: serde::Serialize + for<'a> serde::Deserialize<'a> {
    /// Return a JSON template describing how the AI’s output should be structured.
    /// This might include doc comments or other instructions for each field.
    fn to_template() -> serde_json::Value;
}

We use it during AI assisted struct generation. We want to have the AI intelligently generate values for an arbitrary struct's fields. With this in mind, we need to provide it with a template or a sort of "schema" which contains the information about what it needs to generate and how it should do it.

We use this trate to enable this functionality.

See ai-json-template-derive for the full usage and utility of this functionality.

Happy programming!

Dependencies

~13–29MB
~409K SLoC