Magic Instantiate
Quickstart
use *;
let client = new;
let person: Person = client.instantiate.await?;
// For even more ergonomics, use the `make_magic` macro to create the `magic!` macro
make_magic!;
let person: Person = magic!;
Descriptions and validators can be applied at the field level, or the struct/enum level.
Some basic validators are provided, but you can also define your own by implementing the Validator
trait.
What happens here is the derived MagicInstantiate
trait allows this struct to be represented as a TypeScript type definition.
This type definition plus a few instructions are used as a prompt to the LLM. The output of the LLM is validated and marshalled back into the Rust type. Attempts are made to re-prompt the LLM to fix any validation errors.
With this simple mechanism, you can write entire programs infused with AI.