Example
Let’s create an Movie Agent to write aMovieScript
for us.
movie_agent.py
MovieScript
class, here’s how it looks:
Using a Parser Model
You can use an additional model to parse and structure the output from your primary model. Aparser_model
can be employed to transform the raw response into structured output, replacing the default model for this specific task. This approach is particularly effective when the primary model is optimized for reasoning tasks, as such models may not consistently produce detailed structured responses.
parser_model_prompt
to your Parser Model.
Streaming Structured Output
Streaming can be used in combination withresponse_model
. This returns the structured output as a single event in the stream of events.
streaming_agent.py
Developer Resources
- View Cookbook
- View Parser Model Cookbook
- View Streaming Structured Output