b9cd98addffc674e28684970a014734989e3c79c
RAG Agent with Qdrant and Ollama
Overview
This repository contains a minimal implementation of an AI agent that uses RAG (Retrieval‑Augmented Generation) with a local vector store powered by Qdrant and embeddings from Ollama. The agent can:
- Add documents to the knowledge base.
- Search the knowledge base semantically.
- Answer arbitrary user queries using the stored information.
The project is structured into three main files:
main.py– entry point with an interactive CLI and examples.tools.py– LangChain tools for adding/searching documents.requirements.txt– Python dependencies.
Installation
# Pull required Ollama models (run once)
ollama pull llama3
ollama pull nomic-embed-text
# Install Python packages
pip install -r requirements.txt
Usage
Run the interactive client:
python main.py
You can use the following commands:
/add– add a new document./search <query>– perform a semantic search./quit– exit.- Any other text is treated as a question for the agent.
Architecture
The agent uses LangChain’s create_agent with two custom tools:
- add_to_knowledge_base – splits input into chunks, embeds them via Ollama, and stores in Qdrant.
- search_knowledge_base – performs a similarity search on the vector store.
The LLM is an Ollama llama3 model accessed through LangChain’s ChatOllama. The embeddings are provided by OllamaEmbeddings with the nomic-embed-text model.
Extending
Feel free to add more tools or integrate a persistent Qdrant instance instead of an in‑memory one. The code is intentionally simple for educational purposes.
Description
Languages
Python
100%