define_intent

Attribute Macro define_intent 

Source
#[define_intent]
Expand description

A procedural attribute macro that generates prompt-building functions and extractor structs for intent enums.

This macro should be applied to an enum to generate:

  1. A prompt-building function that incorporates enum documentation
  2. An extractor struct that implements IntentExtractor

§Requirements

The enum must have an #[intent(...)] attribute with:

  • prompt: The prompt template (supports Jinja-style variables)
  • extractor_tag: The tag to use for extraction

§Example

#[define_intent]
#[intent(
    prompt = "Analyze the intent: {{ user_input }}",
    extractor_tag = "intent"
)]
enum MyIntent {
    /// Create a new item
    Create,
    /// Update an existing item
    Update,
    /// Delete an item
    Delete,
}

This will generate:

  • pub fn build_my_intent_prompt(user_input: &str) -> String
  • pub struct MyIntentExtractor; with IntentExtractor<MyIntent> implementation