This project implements a Retrieval-Augmented Generation (RAG) chatbot that answers questions based on the content of a user-uploaded PDF. It uses Langchain for orchestration, Chroma for vector storage, and a local LLM served through Ollama. The system is designed to run locally and logs interactions using LangSmith.
The mistral model was selected for its balance between performance and responsiveness. The project initially used llama3, but it resulted in significantly slower responses, which affected the user experience.
git clone https://github.com/xilenAtenea/chatbot-rag
cd chatbot-ragIf you haven't installed Ollama yet, do it first.
Then open Ollama — it will start running automatically in the background.
Run the following commands to download the models locally:
ollama pull mistral
ollama pull nomic-embed-text
mistralis used for answering questions.nomic-embed-textis used to convert text chunks into vector embeddings.
This project uses
uvto manage dependencies. If you don't haveuv, install it with:
pip install uvThen install the required packages:
uv pip install -r pyproject.tomlCreate a .env file in the root directory with the following content:
LANGSMITH_API_KEY=your_langsmith_api_key
LANGSMITH_TRACING=true
USER_AGENT=chatbot-rag
You can get a free API key at https://smith.langchain.com
Start the Streamlit app:
uv run streamlit run src/app.pyOnce running, you'll be able to:
- Upload a PDF file
- Adjust LLM parameters (
temperature,top_p,top_k) - Ask questions about its content
- See which chunks were used to generate the answer
- View response metadata and trace it on LangSmith
You can try questions like (taking into account the example pdf, where the book "el principito" in Spanish was used):
- ¿Qué representaba realmente el sombrero?
- ¿Quien le dice al principito "lo esencial es invisible para los ojos."?
chatbot-rag/
├── src/
│ ├── app.py # Streamlit UI
│ └── rag_logic.py # PDF processing, RAG logic
├── data/ # Sample PDF
├── imgs/
├── .env # your own API keys and settings
├── .gitignore
├── pyproject.toml
└── README.md

