Skip to main content

Code

structured_output.py

Usage

1

Set up your virtual environment

2

Set your API key

3

Install dependencies

4

Run Agent

Save the code above as structured_output.py, then run:
The example defines a Pydantic model MovieScript and uses it as the agent’s output_schema. The response from IBM WatsonX is parsed into a MovieScript object.