Qdrant
Vector database for similarity search
The Qdrant tool lets an agent run vector similarity search for semantic retrieval and RAG.
Overview
Qdrant is a vector similarity search engine. Use it for semantic search, recommendations, and RAG applications.
Installation
pip install "praisonai[tools]"Environment Variables
export QDRANT_URL=http://localhost:6333
export QDRANT_API_KEY="${QDRANT_API_KEY:?Set QDRANT_API_KEY in your shell}" # Optional for cloudHow It Works
Quick Start
- 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) - 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
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.
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.
qdrant.upsert("documents", [
{"id": 1, "vector": [0.1, 0.2, 0.3], "payload": {"text": "Hello"}}
])create_collection(name, vector_size)
Create a new collection.
qdrant.create_collection("my_collection", vector_size=384)Docker Setup
docker run -d --name qdrant \
-p 6333:6333 \
qdrant/qdrantCommon Errors
| Error | Cause | Solution |
|---|---|---|
qdrant-client not installed | Missing dependency | Run pip install qdrant-client |
Connection refused | Qdrant not running | Start Qdrant server |
Collection not found | Collection doesn’t exist | Create 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.