Skip to main content

Python SDK for Dakera - AI memory platform

Project description

Dakera Python SDK

CI PyPI License: MIT Python

Official Python client for Dakera - a high-performance vector database.

Installation

pip install dakera

For async support:

pip install dakera[async]

Quick Start

from dakera import DakeraClient

# Connect to Dakera
client = DakeraClient("http://localhost:3000")

# Upsert vectors
client.upsert("my-namespace", vectors=[
    {"id": "vec1", "values": [0.1, 0.2, 0.3], "metadata": {"label": "a"}},
    {"id": "vec2", "values": [0.4, 0.5, 0.6], "metadata": {"label": "b"}},
])

# Query similar vectors
results = client.query(
    "my-namespace",
    vector=[0.1, 0.2, 0.3],
    top_k=10,
)

for result in results.results:
    print(f"{result.id}: {result.score}")

Features

  • Vector Operations: Upsert, query, delete, fetch vectors
  • Full-Text Search: Index documents and perform BM25 search
  • Hybrid Search: Combine vector and text search with configurable weights
  • Namespace Management: Create, list, delete namespaces
  • Metadata Filtering: Filter queries by metadata fields
  • Type Hints: Full type annotation support
  • Context Manager: Automatic connection cleanup

Usage Examples

Vector Operations

from dakera import DakeraClient, Vector

client = DakeraClient("http://localhost:3000")

# Using dataclass
vectors = [
    Vector(id="vec1", values=[0.1, 0.2, 0.3], metadata={"category": "A"}),
    Vector(id="vec2", values=[0.4, 0.5, 0.6], metadata={"category": "B"}),
]
client.upsert("my-namespace", vectors)

# Using dictionaries
client.upsert("my-namespace", vectors=[
    {"id": "vec3", "values": [0.7, 0.8, 0.9]},
])

# Query with metadata filter
results = client.query(
    "my-namespace",
    vector=[0.1, 0.2, 0.3],
    top_k=5,
    filter={"category": {"$eq": "A"}},
    include_metadata=True,
)

# Batch query
batch_results = client.batch_query("my-namespace", queries=[
    {"vector": [0.1, 0.2, 0.3], "top_k": 5},
    {"vector": [0.4, 0.5, 0.6], "top_k": 3},
])

# Delete vectors
client.delete("my-namespace", ids=["vec1", "vec2"])
client.delete("my-namespace", filter={"category": {"$eq": "obsolete"}})

Full-Text Search

# Index documents
client.index_documents("my-namespace", documents=[
    {"id": "doc1", "content": "Machine learning is transforming industries"},
    {"id": "doc2", "content": "Vector databases enable semantic search"},
])

# Search
results = client.fulltext_search(
    "my-namespace",
    query="machine learning",
    top_k=10,
)

for result in results:
    print(f"{result.id}: {result.score}")

Hybrid Search

# Combine vector and text search
results = client.hybrid_search(
    "my-namespace",
    vector=[0.1, 0.2, 0.3],  # Embedding of query
    query="machine learning",  # Text query
    top_k=10,
    alpha=0.7,  # 0 = pure vector, 1 = pure text
)

for result in results:
    print(f"{result.id}: score={result.score}, vector={result.vector_score}, text={result.text_score}")

Namespace Management

# Create namespace with specific configuration
client.create_namespace(
    "embeddings",
    dimensions=384,
    index_type="hnsw",
)

# List all namespaces
namespaces = client.list_namespaces()
for ns in namespaces:
    print(f"{ns.name}: {ns.vector_count} vectors")

# Get namespace info
info = client.get_namespace("embeddings")
print(f"Dimensions: {info.dimensions}, Index: {info.index_type}")

# Delete namespace
client.delete_namespace("old-namespace")

Metadata Filtering

Dakera supports rich metadata filtering:

# Equality
filter = {"status": {"$eq": "active"}}

# Comparison
filter = {"price": {"$gt": 100, "$lt": 500}}

# In list
filter = {"category": {"$in": ["electronics", "books"]}}

# Logical operators
filter = {
    "$and": [
        {"status": {"$eq": "active"}},
        {"price": {"$lt": 1000}},
    ]
}

results = client.query(
    "products",
    vector=query_embedding,
    filter=filter,
    top_k=20,
)

Error Handling

from dakera import (
    DakeraClient,
    NotFoundError,
    ValidationError,
    RateLimitError,
)

client = DakeraClient("http://localhost:3000")

try:
    results = client.query("nonexistent", vector=[0.1, 0.2])
except NotFoundError as e:
    print(f"Namespace not found: {e}")
except ValidationError as e:
    print(f"Invalid request: {e}")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after} seconds")

Context Manager

with DakeraClient("http://localhost:3000") as client:
    client.upsert("my-namespace", vectors=[...])
    results = client.query("my-namespace", vector=[...])
# Connection automatically closed

Authentication

# With API key
client = DakeraClient(
    "http://localhost:3000",
    api_key="your-api-key",
)

# With custom headers
client = DakeraClient(
    "http://localhost:3000",
    headers={"X-Custom-Header": "value"},
)

Configuration

Parameter Type Default Description
base_url str required Dakera server URL
api_key str None API key for authentication
timeout float 30.0 Request timeout in seconds
max_retries int 3 Max retries for failed requests
headers dict None Additional HTTP headers

API Reference

DakeraClient

Vector Operations

  • upsert(namespace, vectors) - Insert or update vectors
  • query(namespace, vector, top_k, filter, ...) - Query similar vectors
  • delete(namespace, ids, filter, delete_all) - Delete vectors
  • fetch(namespace, ids) - Fetch vectors by ID
  • batch_query(namespace, queries) - Execute multiple queries

Full-Text Operations

  • index_documents(namespace, documents) - Index documents
  • fulltext_search(namespace, query, top_k, filter) - Text search
  • hybrid_search(namespace, vector, query, alpha, ...) - Hybrid search

Namespace Operations

  • list_namespaces() - List all namespaces
  • get_namespace(namespace) - Get namespace info
  • create_namespace(namespace, dimensions, index_type) - Create namespace
  • delete_namespace(namespace) - Delete namespace

Admin Operations

  • health() - Check server health
  • get_index_stats(namespace) - Get index statistics
  • compact(namespace) - Trigger compaction
  • flush(namespace) - Flush pending writes

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy src/dakera

# Linting
ruff check src/

Related Repositories

Repository Description
dakera Core vector database engine (Rust)
dakera-js TypeScript/JavaScript SDK
dakera-go Go SDK
dakera-rs Rust SDK
dakera-cli Command-line interface
dakera-mcp MCP Server for AI agent memory
dakera-dashboard Admin dashboard (Leptos/WASM)
dakera-docs Documentation
dakera-deploy Deployment configs and Docker Compose
dakera-cortex Flagship demo with AI agents

License

MIT License - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dakera-0.1.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dakera-0.1.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file dakera-0.1.0.tar.gz.

File metadata

  • Download URL: dakera-0.1.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dakera-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3dbb7faa15e521cacfbc8a0487ff6ac7ae61c953bd98f1048ed69d3fb6bafa12
MD5 7bf34cae9585c4e5d8cd7831f60e9903
BLAKE2b-256 e938b256f0af3b542a75bc2927e8c678a1242c1a7a9dfe3a84c60229dc1e15fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for dakera-0.1.0.tar.gz:

Publisher: release.yml on Dakera-AI/dakera-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dakera-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dakera-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dakera-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32ed1194ca229613e6f9fbda6b0d79d6a224c7b32c6fe000b9509179c0648c56
MD5 96a7dc09a1a3911de5b312953bbd1aa3
BLAKE2b-256 700297c6bc3e395bad940cd9dd59621928951bce00d88933d74f608dc0a978ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for dakera-0.1.0-py3-none-any.whl:

Publisher: release.yml on Dakera-AI/dakera-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page