A complex structured output agent demonstrating advanced Pydantic schemas for product review analysis.
Sign in to save downloads to your library and vote.
Preview
Product Review Agent
A complex structured output agent demonstrating advanced Pydantic schemas for product review analysis.
๐ฏ What This Demonstrates
- Complex Schemas: Multi-field Pydantic models with various data types
- List Fields: Arrays of strings for pros/cons analysis
- Boolean Logic: Recommendation decisions based on review content
- Sentiment Analysis: Automated sentiment classification
๐ Quick Start
-
Install OpenAI Agents SDK:
pip install openai-agents -
Set up environment:
cp ../env.example .env # Edit .env and add your OpenAI API key -
Run the agent:
from agents import Runner from agent import root_agent review_text = "This laptop is amazing! Great performance, long battery life, but a bit heavy." result = Runner.run_sync(root_agent, f"Analyze this review: {review_text}") print(result.final_output) # Returns ProductReview object
๐ก Key Concepts
- Rating Validation: Integer constraints (1-5 stars)
- Sentiment Enum: Automatic positive/negative/neutral classification
- List Processing: Extracting multiple pros and cons
- Optional Fields: Handling missing reviewer information
๐งช Example Output
{
"product_name": "Gaming Laptop XYZ",
"rating": 4,
"summary": "Great performance but heavy design",
"sentiment": "positive",
"pros": ["Great performance", "Long battery life", "Good display"],
"cons": ["Heavy weight", "Expensive price"],
"recommend": true,
"reviewer_name": "TechEnthusiast123"
}
๐ Next Steps
- Support Ticket Agent - Basic structured output
- Tutorial 3: Tool Using Agent - Adding tools to agents
Ingestion metadata
- Source catalog
- awesome-llm-apps
- Repository
- Shubhamsaboo/awesome-llm-apps ยท main
- File path
- ai_agent_framework_crash_course/openai_sdk_crash_course/2_structured_output_agent/2_2_product_review_agent/README.md
- Last refreshed
- 7/23/2026, 10:39:09 PM (4h ago)
- Refresh schedule
- Daily ยท 03:00 UTC
- Dedupe status
- Unique ยท deduped by (source, url)