Skip to content

Structured Output

class AgentResponse(BaseModel):
    answer: str = Field(
        description="The agent's answer to the query",
    )
    magic_numbers: list[int] = Field(
        default_factory=list,
        description="A short list with random numbers",
    )

agent = create_agent(
    model="ollama:llama3.2",
    tools=[get_weather],
    system_prompt="You are a helpful assistant",
    response_format=AgentResponse,
)