Generate grounded code with RAG

Use RagCodeGenWorkflow when you need to generate code that cites real attune APIs, workflow names, and CLI commands — retrieved from attune-help context and verified against actual source documentation.

Prerequisites

Instantiate and execute the workflow

  1. Import RagCodeGenWorkflow. Add the following import to your module:

    from workflows.rag_code_gen import RagCodeGenWorkflow
    
  2. Instantiate the workflow. Pass any configuration as keyword arguments to __init__:

    workflow = RagCodeGenWorkflow(**your_kwargs)
    
  3. Call execute to run the workflow. Pass your generation parameters as keyword arguments. The method returns a WorkflowResult:

    result = workflow.execute(**your_kwargs)
    
  4. Inspect the result for provenance. The WorkflowResult includes citations sourced from retrieved attune-help passages. Verify that any referenced APIs, workflow names, and CLI commands appear in those citations — the workflow is designed never to invent attune features.

  5. Run the related tests to confirm your usage is correct:

    pytest -k "rag-grounding"
    

Verify success

Your call succeeded when execute returns a WorkflowResult without raising an exception and the result contains citations that trace back to real attune-help source files. If the output references an attune feature that does not appear in the cited passages, the grounding has failed and you should review the context retrieval step.

Key files