#[Signature] macro generates an implementation of the MetaSignature trait for your type.
What is a signature?
- Purpose: Describe a task contract: structured inputs, structured outputs, and an optional instruction.
- Rust shape: A normal Rust
structannotated with#[Signature]and field attributes (#[input],#[output]). - Trait impl: The macro implements
MetaSignature(introspection of input/output fields, instruction, demos).
Defining a signature
- Doc comments: The
///above the struct become the signature’s instruction (used by adapters). - Field roles: Mark inputs vs. outputs with attributes for clear orchestration.
Inline macro alternative
Demos (few-shot examples)
You can attach examples at runtime for few-shot prompting.Where it fits
- A
Signaturedoes not call the LM by itself; aPredictoruses it, via anAdapter, to build aChatand parse aPrediction. - Keeping the task contract as data (the signature) supports reuse, testing, and optimizer integration later.
