Function generate_prompt

Source
pub fn generate_prompt(
    workflow: Arc<dyn WorkflowLike>,
    capability: &Capability,
) -> Result<(String, String)>
Expand description

Generate structured prompts from workflow rules for AI model inference

This function analyzes a workflow and converts its rules into a structured prompt suitable for AI model inference. It handles modifier rules (UPPERCASE identifiers) and assignment rules (_ prefix) to create a well-formatted prompt that guides AI models to produce the desired outputs.

§Arguments

  • workflow - An Arc-wrapped workflow containing the rules to process
  • capability - The capability level of the target AI model, which determines the formatting complexity of the generated prompt

§Returns

Returns a tuple containing:

  • system_prompt: The system-level prompt (can be overridden by SYSTEM rule)
  • user_prompt: The structured user prompt with sections and formatting

§Errors

Returns an error if:

  • No assignment rules are found (nothing to populate)
  • Workflow rules cannot be processed