Qdrant

Vector database for similarity search

The Qdrant tool lets an agent run vector similarity search for semantic retrieval and RAG.

Diagram

Qdrant

User

Agent

QdrantTool

Qdrant

Matches

Overview

Qdrant is a vector similarity search engine. Use it for semantic search, recommendations, and RAG applications.

Installation

bash
pip install "praisonai[tools]"

Environment Variables

bash
export QDRANT_URL=http://localhost:6333
export QDRANT_API_KEY="${QDRANT_API_KEY:?Set QDRANT_API_KEY in your shell}"  # Optional for cloud

How It Works

Diagram
QdrantQdrantToolAgentUserQdrantQdrantToolAgentUser“Find similar items”search(collection, vector)vector searchnearest matchesresultsfinal answer

Quick Start

  1. Simple Usage
    python
    from praisonai_tools import QdrantTool
    
    # Initialize
    qdrant = QdrantTool(url="http://localhost:6333")
    
    # Search
    results = qdrant.search("products", query_vector=[0.1, 0.2, ...], limit=5)
    print(results)
  2. With Configuration

    Use the same tool with an agent — see Usage with Agent below, or pass env vars and options from the sections above.

Usage with Agent

python
from praisonaiagents import Agent
from praisonai_tools import QdrantTool

qdrant = QdrantTool(url="http://localhost:6333")

agent = Agent(
    name="SearchAgent",
    instructions="You perform semantic search using Qdrant.",
    tools=[qdrant]
)

response = agent.chat("Find similar products to item 123")
print(response)

Available Methods

search(collection, query_vector, limit=10)

Search for similar vectors.

python
from praisonai_tools import QdrantTool

qdrant = QdrantTool(url="http://localhost:6333")
results = qdrant.search("documents", query_vector=[0.1, 0.2, 0.3], limit=5)

upsert(collection, points)

Insert or update points.

python
qdrant.upsert("documents", [
    {"id": 1, "vector": [0.1, 0.2, 0.3], "payload": {"text": "Hello"}}
])

create_collection(name, vector_size)

Create a new collection.

python
qdrant.create_collection("my_collection", vector_size=384)

Docker Setup

bash
docker run -d --name qdrant \
    -p 6333:6333 \
    qdrant/qdrant

Common Errors

ErrorCauseSolution
qdrant-client not installedMissing dependencyRun pip install qdrant-client
Connection refusedQdrant not runningStart Qdrant server
Collection not foundCollection doesn’t existCreate collection first

Best Practices

Load QDRANT_API_KEY from the environment

For Qdrant Cloud, set QDRANT_API_KEY in your shell or .env. Local instances need only QDRANT_URL.

Match vector dimensions

create_collection(name, vector_size) must match your embedding model’s dimension. A mismatch causes search errors, so keep the size aligned with the encoder the agent uses.

Cap the search limit

search(collection, query_vector, limit=10) defaults to 10. Return only as many matches as the agent needs to keep context small.

Related Tools