A RAG to chat with multiple PDF files using Google Gemini LLM.
The following components are required to run ChatPDF application.
You need to get an API key from Gemini. Google also provides free API keys.
We are storing the embeddings in MongoDB to perform Vector Search. This feature is available on cloud-based version of MongoDB, aka. MongoDB Atlas. You can create a free account on its website.
Once a cluster is created on MongoDB Atlas, go ahead to create a database and a collection. A vector search index with the following format should be created on the created collection.
"fields": [
{
"type": "vector",
"numDimensions": 768,
"path": "embedding",
"similarity": "cosine"
},
{
"type": "filter",
"path": "file_name"
}
]A Streamlit secrets file should be created in .streamlit/secrets.toml with the following format, providing the details of the API key and MongoDB settings:
[Gemini]
GEMINI_API_KEY = "api_key_here"
LLM_MODEL = "gemini-2.0-flash"
EMBED_MODEL = "models/text-embedding-004"
[MongoDB]
URI = "mongodb+srv://<username>:<password>@<cluster_name>.qwar6.mongodb.net/"
DB = "pdf"
COLLECTION = "embeddings"In order to run this tool, you must have Streamlit installed on your machine/environment:
streamlit run app.py
This project is open-source, and it is available on Github at https://github.com/kavehbc/chat-pdf.
Kaveh Bakhtiyari - Website | Medium | LinkedIn | GitHub
Feel free to join the open-source community and contribute to this repository.
