2026-05-27 14:37:14 +00:00
2026-05-27 14:34:21 +00:00
2026-05-27 14:37:14 +00:00
2026-05-27 14:36:52 +00:00

RAG Agent with Qdrant and Ollama

Overview

This repository contains a minimal implementation of an AI agent that uses RAG (RetrievalAugmented Generation) with a local vector store powered by Qdrant and embeddings from Ollama. The agent can:

  1. Add documents to the knowledge base.
  2. Search the knowledge base semantically.
  3. 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 LangChains create_agent with two custom tools:

  1. add_to_knowledge_base splits input into chunks, embeds them via Ollama, and stores in Qdrant.
  2. search_knowledge_base performs a similarity search on the vector store.

The LLM is an Ollama llama3 model accessed through LangChains 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 inmemory one. The code is intentionally simple for educational purposes.

S
Description
No description provided
Readme 31 KiB
Languages
Python 100%