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
- Read access to
src/attune/workflows/rag_code_gen.py - A Python environment where you can import from
workflows.rag_code_gen
Instantiate and execute the workflow
-
Import
RagCodeGenWorkflow. Add the following import to your module:from workflows.rag_code_gen import RagCodeGenWorkflow -
Instantiate the workflow. Pass any configuration as keyword arguments to
__init__:workflow = RagCodeGenWorkflow(**your_kwargs) -
Call
executeto run the workflow. Pass your generation parameters as keyword arguments. The method returns aWorkflowResult:result = workflow.execute(**your_kwargs) -
Inspect the result for provenance. The
WorkflowResultincludes 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. -
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
src/attune/workflows/rag_code_gen.py— definesRagCodeGenWorkflowand itsexecutemethod