This project allows you to have interactive conversations with PDF documents using Google's Gemini AI for natural language processing and understanding.
Prerequisites
- Node.js (v18 or higher)
- npm or yarn
- Google AI Studio account (for Gemini API key)
- PDF documents you want to interact with
- Set up environment variables:
Create a
.env
file in the root directory with the following content:
GEMINI_API_KEY=your_api_key_here
- Go to Google AI Studio
- Sign in with your Google account
- Click on "Get API key" or "Create API key"
- Copy the generated API key
- Paste it into your
.env
file, replacingyour_api_key_here
You can run the project in two ways:
- Using npm scripts:
# Start the chat with a PDF file
npm run chat path/to/your/document.pdf
# Or with a custom prompt
npm run chat path/to/your/document.pdf "Your custom prompt here"
- Using tsx directly:
# Start the chat with a PDF file
npx tsx src/index.ts path/to/your/document.pdf
# Or with a custom prompt
npx tsx src/index.ts path/to/your/document.pdf "Your custom prompt here"
Once started, you can:
- Ask questions about the PDF content
- Type 'exit' to quit the chat
- The AI will respond based on the content of your PDF
- PDF document upload and processing
- Interactive chat interface
- Context-aware responses using Gemini AI
- Real-time conversation history
- Custom prompt support
chat-with-a-pdf/
├── src/ # Source files
│ └── index.ts # Main application code
├── .env # Environment variables
├── package.json # Project dependencies and scripts
└── README.md # Project documentation
This project is licensed under the ISC License - see the LICENSE file for details.