What You’ll Learn
| Concept | Description |
|---|---|
| Structured Output | Using Pydantic schemas for consistent agent responses |
| Document Loading | Reading PDFs, text files, and web pages |
| Entity Extraction | Identifying people, organizations, dates, technologies |
| Action Items | Finding tasks and next steps in documents |
Prerequisites
- Python 3.12+
- OpenAI API key
Setup
1
Clone the repository
2
Create and activate virtual environment
3
Install dependencies
4
Set environment variables
Run the Agent
Basic Summary
Summarize a document and access structured fields:- Summarizing a text file
- Accessing structured summary fields
- Displaying key points and entities
Entity Extraction
Focus on extracting and categorizing entities:- Entity extraction from documents
- Categorizing by type (person, organization, date, etc.)
- Contextual information for each entity
Batch Processing
Process multiple documents:Agent Configuration
| Parameter | Purpose |
|---|---|
model | GPT-5.2 for document understanding |
output_schema | Pydantic model for structured output |
read_pdf | Extract text from PDF files |
read_text_file | Read .txt and .md files |
fetch_url | Fetch and clean web page content |
ReasoningTools | Plan extraction approach before summarizing |
How It Works
Document Processing
Output Schema
Document Type Detection
| Type | Indicators |
|---|---|
report | Formal structure, findings, conclusions |
article | News format, byline, publication date |
meeting_notes | Attendees, agenda, discussion items |
research_paper | Abstract, methodology, citations |
email | To/From headers, subject line |
Troubleshooting
PDF extraction returns empty text
PDF extraction returns empty text
The PDF may be image-based (scanned). This agent handles text-based PDFs only. For scanned documents, use the Invoice Analyst which has vision capabilities.
Web page content is incomplete
Web page content is incomplete
JavaScript-heavy pages may not extract fully. The agent uses BeautifulSoup for static HTML extraction.
Low confidence score
Low confidence score
Low confidence indicates poor document quality, ambiguous content, or missing context. Review the document manually and provide additional context if needed.