Back to prompt library
Define Pydantic Models for Output Structures
Linked challenge: Agent for Ethical, Personalized Content Recommendation
Prompt source
planning1 lines1 sectionsNo variables0 checklist items
Using Pydantic, define two robust data models: `ArticleSummary` and `RecommendationItem`. `ArticleSummary` should include fields like `title`, `key_points` (list of strings), and `sentiment`. `RecommendationItem` should contain `article_id`, `title`, `relevance_score` (float), and `reason`. These models will enforce the structure of your agent's outputs. Provide the Python code for these Pydantic models.