Pydantic validates and serializes Python data against schemas declared with type annotations. Its BaseModel class lets an application define structured fields and check incoming data. section 9.3.1
A Pydantic model can provide:
- Data validation, type checking, and serialization inherited from BaseModel. section 9.3.1
- A structured response format for OpenAI Structured Outputs, making LLM results easier to parse programmatically. section 9.3.1
Evaluating a quiz answer
Define AnswerEvaluation with is_correct: bool and correct_answer: str, then pass it as the response schema when evaluating a player's answer. The application can display success or show the correct answer using the parsed fields.



