An intelligent AI agent that understands and answers questions about any PDF document using Google Gemini AI and advanced retrieval techniques.
- for example i upload a resume and ask some question and you can see response below
- Reads and understands PDF document content
- Creates semantic embeddings for intelligent search
- Answers natural language questions about the PDF
- Provides accurate, context-aware responses through RAG
- Node.js (v14+)
- Google Gemini API key
-
Install dependencies:
npm install npm install @google/generative-ai @langchain/google-genai
-
Create
.envfile:GEMINI_API_KEY=your_api_key_here -
Place your PDF document in
data/folder (e.g.,data/document.pdf) -
Start the AI agent:
npx tsc npm run dev
The agent initializes on port 3000 and begins learning from your PDF document.
Ask the agent questions about the PDF content:
curl -X POST http://localhost:3000/ask \
-H "Content-Type: application/json" \
-d '{"question": "What are the key points mentioned in this document?"}'The AI agent responds with intelligent answers:
{
"answer": "Based on the document, the key points include..."
}- Visit: https://aistudio.google.com/app/apikey
- Sign in and create a new API key
- Add it to your
.envfile
src/
├── index.ts # Agent API server
├── agent.ts # AI agent logic
└── ingest.ts # PDF processing
data/
└── your_document.pdf
- Check your
GEMINI_API_KEYin.env - Ensure PDF is in
data/folder - Run
npx tscto check for compilation errors