Skip to main content

A tool for interacting with PDF documents using AI, allowing page-specific prompts and summaries. PDFConverse leverages Gemini API to provide intelligent responses to queries about PDF content, optimizing token usage and enabling focused analysis of specific page ranges.

Project description

SmartPDF

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.

Features

  • 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

Installation

You can install PDFConverse using pip:

pip install pdfconverse

Usage

Here's a basic example of how to use PDFConverse: This example shows how to use it directly from files if you have acccess to underlying file system.

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
file_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(gemini_setup=gemini_setup,file_path=file_path)

# Get a summary of the first page
summary = pdfconverse.page(page_start=0, page_end=0).prompt("Give me a summary")
print(summary)

This examples shows where you are streaming eg if you need to use s3

file_path = "./src/pdfconverse/samples/gemini_test_file.pdf"
with open(file_path, "rb") as f:
    pdf_bytes = BytesIO(f.read())
pdfconverse = PDFConverse(gemini_setup=gemini_setup,bytes=pdf_bytes)
# Get a summary of the first page
summary = pdfconverse.page(page_start=0, page_end=0).prompt("Give me a summary")
print(summary)

Use Cases

  1. Reading Aid: Use PDFConverse as a reading assistant, summarizing individual pages as you go through a document.
  2. Targeted Analysis: Focus on specific sections of a large document without processing unnecessary content.
  3. Document Q&A: Ask questions about particular pages or sections of your PDF.

Caution

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.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the Gemini API for powering the AI interactions
  • Inspired by the need for more granular control over AI-document interactions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdfconverse-0.1.3.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdfconverse-0.1.3-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file pdfconverse-0.1.3.tar.gz.

File metadata

  • Download URL: pdfconverse-0.1.3.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for pdfconverse-0.1.3.tar.gz
Algorithm Hash digest
SHA256 419ab46ef2b55b0738b9a673ef3abf7e3963cf05e7ef67a6d37a96195908dcfa
MD5 382fe3c88ada57d65cbe8738ed8c4a18
BLAKE2b-256 d956743b81345f001fb716ff1343ded8d6c4d3e08dd1f0f59b8d639c839baeba

See more details on using hashes here.

File details

Details for the file pdfconverse-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pdfconverse-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for pdfconverse-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fcb62851031022d9794cbac30c6c27d6cbc348af2093788caf40862b04fb1eb0
MD5 74e51a754b0ac7a8e33e1b0452cb1981
BLAKE2b-256 291bc5d19f96df637787d5002fc5a036487a9fa15b15ec6d6b8f78c9d671cfd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page