Building AI agents, atomically
Basic PDF Analysis Example
This example demonstrates how to use the Atomic Agents framework to analyze a PDF file, using Google generative AI's multimodal capabilities.
Features
- PDF document analysis: Process a PDF document using Google generative AI multimodal capability.
- Structured Data Extraction: Extract key information from PDFs into a structured Pydantic model:
- Document title
- Page count
Getting Started
Clone the main Atomic Agents repository:
git clone https://github.com/eigenwise/atomic-agentsNavigate to the basic-pdf-analysis directory:
cd atomic-agents/atomic-examples/basic-pdf-analysisInstall dependencies using uv:
uv syncSet up environment variables: Create a
.envfile in thebasic-pdf-analysisdirectory with the following content:GEMINI_API_KEY=your_gemini_api_keyReplace
your_gemini_api_keywith your actual google generative AI key.Run the example:
uv run python basic_pdf_analysis/main.py
Components
1. Input/Output Schemas
InputSchema: Handles the input PDF fileExtractionResult: Structures the extracted information
2. Agent
A specialized agent configured with:
- Google generative AI gemini-2.0-flash model
- Custom system prompt
- Structured data validation
Example Usage
The example includes a test PDF file in the test_media directory.
Running the example will:
- Load the PDF from the
test_mediadirectory - Process it with the agent
- Display the extracted information:
- PDF title
- Page count
Example output:
Starting PDF file analysis...
Analyzing PDF file: pdf_sample.pdf ...
===== Analysis Results =====
PDF Title: Sample PDF Document
Page Count: 3
Document summary: This PDF is three pages long and contains Latin text.
Analysis completed successfully
Customization
You can modify the example by:
- Adding your own files to the
test_mediadirectory - Adjusting the
ExtractionResultschema to capture additional information - Modifying the system prompts to extract different or additional information
Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your enhancements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for details.