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

RAG Agent with Qdrant and Ollama

Project Overview

This repository contains a minimal yet complete implementation of an AI agent that can search and add information to a local knowledge base powered by Qdrant (vector database) and Ollama (local LLM & embeddings). The agent is built using the LangChain framework.

The main components are:

  • Vector store Qdrant client with an initialized collection.
  • Text splitter RecursiveCharacterTextSplitter for chunking documents.
  • Embedding model OllamaEmbeddings (nomic-embed-text).
  • LLM ChatOllama (llama3).
  • Tools search_knowledge_base and add_to_knowledge_base.
  • Agent created with create_agent from LangChain.
  • CLI client simple interactive loop to demonstrate adding documents and searching the knowledge base.

Directory Structure

├── README.md
├── requirements.txt
├── main.py          # CLI entry point
├── agent.py         # Agent creation logic
├── tools.py         # LangChain tool definitions
├── utils.py         # Qdrant client, splitter, and helper functions
└── docs/            # Directory with text files to load initially (optional)

Installation

# Pull required Ollama models
ollama pull llama3
ollama pull nomic-embed-text

# Install Python dependencies
pip install -r requirements.txt

Usage

  1. Load documents Place any .txt files in the docs/ directory.
  2. Run the CLI:
    python main.py
    
  3. In the interactive prompt you can use:
    • /add <file_path> Add a new document to the knowledge base.
    • /search <query> Search the knowledge base and display results.
    • /quit Exit the program.

Example

> /search python data structures
1. Python lists are ordered collections...
2. Tuples are immutable sequences...

Architecture

  • The agent is a LangChain agent that uses two tools: search_knowledge_base and add_to_knowledge_base. It receives user messages, decides which tool to call, and returns the result.
  • The vector store is wrapped by QdrantVectorStore, which handles embedding generation via OllamaEmbeddings. Documents are split into chunks before insertion.
  • The CLI orchestrates loading documents at startup and provides a simple REPL for demonstration purposes.

License

MIT © 2026

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