What You’ll Learn
- Implementing a Haystack
@componentwithcomponent.output_typesthat runs Python in a Declaw sandbox - Connecting the component in a Haystack
PipelinealongsideOpenAIGeneratorandPromptBuilder - Demo mode that exercises the component directly without needing an OpenAI key
Prerequisites
- Declaw instance running and
DECLAW_API_KEY/DECLAW_DOMAINset OPENAI_API_KEY(optional — the example runs in demo mode without it)
This example is available in Python. TypeScript support coming soon.
Code Walkthrough
1. Define the DecawCodeRunner component
Use the @component decorator and declare output types with @component.output_types. The run() method receives typed inputs and returns a dict matching the declared output types:
output and exit_code output names can be connected to downstream components in the pipeline by referencing code_runner.output and code_runner.exit_code.