Skip to main content

ThothAI Qdrant

A native Qdrant implementation for the ThothAI Vector Database system, providing high-performance vector storage and similarity search capabilities without Haystack dependencies.

Features

  • Native Qdrant Integration: Direct use of Qdrant client without Haystack
  • Full API Compatibility: Same interface as thoth_vdb2 for seamless integration
  • External Embeddings: Support for OpenAI, Cohere, Mistral, and HuggingFace
  • Document Types: EvidenceDocument, SqlDocument, ColumnNameDocument
  • Similarity Search: Native Qdrant search with document type filtering
  • Batch Operations: Efficient bulk document insertion
  • Caching: Intelligent embedding cache for performance

Installation

# Basic installation
pip install thoth-qdrant

# With OpenAI embeddings support
pip install thoth-qdrant[openai]

# With all embedding providers
pip install thoth-qdrant[all-providers]

Configuration

Environment Variables (v0.1.10+)

Starting from version 0.1.10, embedding configuration is managed exclusively through environment variables:

# Required: Embedding provider configuration
export EMBEDDING_PROVIDER=openai
export EMBEDDING_MODEL=text-embedding-3-small
export OPENAI_API_KEY=your-api-key

# Optional: Advanced configuration
export EMBEDDING_BASE_URL=https://api.openai.com/v1  # Custom API endpoint
export EMBEDDING_BATCH_SIZE=100  # Batch size for embedding requests
export EMBEDDING_TIMEOUT=30  # Request timeout in seconds

# Provider-specific API keys
export OPENAI_API_KEY=sk-...
export COHERE_API_KEY=...
export MISTRAL_API_KEY=...

Qdrant Setup

Ensure Qdrant is running locally:

docker run -p 6333:6333 qdrant/qdrant

Usage

from thoth_qdrant import VectorStoreFactory
from thoth_qdrant.core.base import (
    ColumnNameDocument,
    SqlDocument,
    EvidenceDocument,
    ThothType,
)

# Create vector store
store = VectorStoreFactory.create(
    backend="qdrant",
    collection="my_collection",
    host="localhost",
    port=6333,
    embedding_provider="openai",
    embedding_model="text-embedding-3-small"
)

# Add documents
column_doc = ColumnNameDocument(
    table_name="users",
    column_name="email",
    original_column_name="email_address",
    column_description="User email for authentication",
    value_description="Valid email format"
)
doc_id = store.add_column_description(column_doc)

sql_doc = SqlDocument(
    question="How to find recent users?",
    sql="SELECT * FROM users WHERE created_at > NOW() - INTERVAL '30 days'",
    evidence="Filter by date using interval"
)
store.add_sql(sql_doc)

# Search similar documents
results = store.search_similar(
    query="user email authentication",
    doc_type=ThothType.COLUMN_NAME,
    top_k=5,
    score_threshold=0.7
)

# Bulk operations
documents = [column_doc, sql_doc]
doc_ids = store.bulk_add_documents(documents)

# Get document by ID
doc = store.get_document(doc_id)

# Delete document
store.delete_document(doc_id)

# Get all documents by type
all_columns = store.get_all_column_documents()
all_sql = store.get_all_sql_documents()

# Collection info
info = store.get_collection_info()
print(info)

# Get embedding configuration (v0.1.10+)
embedding_config = store.get_embedding_config()
print(f"Provider: {embedding_config['provider']}")
print(f"Model: {embedding_config['model']}")
print(f"Dimensions: {embedding_config['dimensions']}")
print(f"Cache enabled: {embedding_config['cache_enabled']}")

API Reference

VectorStoreInterface Methods

  • add_column_description(doc: ColumnNameDocument) -> str
  • add_sql(doc: SqlDocument) -> str
  • add_evidence(doc: EvidenceDocument) -> str
  • search_similar(query: str, doc_type: ThothType, top_k: int = 5, score_threshold: float = 0.7) -> List[BaseThothDocument]
  • get_document(doc_id: str) -> Optional[BaseThothDocument]
  • delete_document(doc_id: str) -> None
  • bulk_add_documents(documents: List[BaseThothDocument]) -> List[str]
  • delete_collection(thoth_type: ThothType) -> None
  • get_all_column_documents() -> List[ColumnNameDocument]
  • get_all_sql_documents() -> List[SqlDocument]
  • get_all_evidence_documents() -> List[EvidenceDocument]
  • get_collection_info() -> Dict[str, Any]
  • get_embedding_config() -> Dict[str, Any] (v0.1.10+)

Testing

# Run tests with local Qdrant
pytest tests/

# Run specific test
pytest tests/test_qdrant_adapter.py -v

# With coverage
pytest --cov=thoth_qdrant tests/

Development

# Install development dependencies
pip install -e .[dev,test]

# Format code
black thoth_qdrant tests
isort thoth_qdrant tests

# Type checking
mypy thoth_qdrant

# Linting
ruff thoth_qdrant

License

Apache License 2.0 - See LICENSE.md for details

Compatibility

This library is fully compatible with thoth_vdb2 API, allowing seamless migration from Haystack-based implementations to native Qdrant.

Metadata

Release files for thoth-qdrant 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thoth-qdrant 0.1.11
File Size Uploaded Provenance Actions
thoth_qdrant-0.1.11.tar.gz 30.8 kB Without provenance Details for thoth_qdrant-0.1.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thoth-qdrant 0.1.11
File Interpreter ABI Platform Actions
thoth_qdrant-0.1.11-py3-none-any.whl Python 3 none any Details for thoth_qdrant-0.1.11-py3-none-any.whl

Total release size: 55.6 kB

Release files / thoth_qdrant-0.1.11.tar.gz

Download URL thoth_qdrant-0.1.11.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d5e252a780de2e04ec849cc32c00995c98a15d5afbf3f9adb3c3bc1acd7d9f69
BLAKE2b-256 checksum
How to use checksums
c14f6f93470b0827b4e948b98bfa67de324ab3fa4c5afee6da90f59f01c7894b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / thoth_qdrant-0.1.11-py3-none-any.whl

Download URL thoth_qdrant-0.1.11-py3-none-any.whl
Size 24.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20265bbf74a5d1ccec5beeed2acbfd68c4c6d604737e888fc1166205b089e9f2
BLAKE2b-256 checksum
How to use checksums
0c6bdc33d5e4a276e63881b3f9a6d4cc00d6df326966bcb316b64ba7b390b32e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Security for thoth-qdrant 0.1.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page