A schema
A list of topics
output_pydantic makes the reply a value that matches a class you defined. The fields are the shape.
The class is a pydantic model. chat sends the request and parses the reply into that class. Each topic is printed on its own line.
Example
from praisonai import Agent
from pydantic import BaseModel
class TopicList(BaseModel):
topics: list[str]
agent = Agent(instructions="Reply with the fields you are given.")
result = agent.chat("List 3 AI topics", output_pydantic=TopicList)
for topic in result.topics:
print(topic)Example explained
- BaseModel — The pydantic base for a schema.
- output_pydantic — The class the reply must match.
Reference: documentation