IBM
Agent with Structured Output
Code
cookbook/models/ibm/watsonx/structured_output.py
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
2
Set your API key
3
Install libraries
4
Run Agent
This example shows how to use structured output with IBM WatsonX. It defines a Pydantic model MovieScript
with various fields and their descriptions, then creates an agent using this model as the response_model
. The model’s output will be parsed into this structured format.