PDFConverse is a Python tool that allows you to interact with PDF documents using AI, leveraging the Gemini API to provide intelligent responses to queries about PDF content. It optimizes token usage and enables focused analysis of specific page ranges.
- Interact with individual pages or page ranges in your PDF
- Run AI-powered prompts on specific sections of your document
- Avoid the problem of passing too much information to the model
- Save tokens by targeting specific pages or ranges
- Built-in sanity checks for better performance and reliability
You can install PDFConverse using pip:
pip install pdfconverse
Here's a basic example of how to use PDFConverse:
import os
from pdfconverse import PDFConverse
from pdfconverse.models import FilePath,GeminiSetup
# Set up your PDF path and Gemini API key. Assuming you have a .env file with the Gemini API key
pdf_path = FilePath(path="./path/to/your/document.pdf")
gemini_setup=GeminiSetup(api_key=os.getenv("GEMINI_API_KEY"),model="gemini-1.5-flash")
# Initialize PDFConverse
pdfconverse = PDFConverse(pdf_path=pdf_path, gemini_setup=gemini_setup)
# Get a summary of the first page
summary = pdfconverse.page(page_start=0, page_end=0).prompt("Give me a summary")
print(summary)
- Reading Aid: Use PDFConverse as a reading assistant, summarizing individual pages as you go through a document.
- Targeted Analysis: Focus on specific sections of a large document without processing unnecessary content.
- Document Q&A: Ask questions about particular pages or sections of your PDF.
While PDFConverse can summarize or interact with entire books, please be aware that this may lead to expensive bills from the Gemini API. Always monitor your usage and costs.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the Gemini API for powering the AI interactions
- Inspired by the need for more granular control over AI-document interactions