Python SDK for Dakera - AI memory platform
Project description
Dakera Python SDK
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 vectorsquery(namespace, vector, top_k, filter, ...)- Query similar vectorsdelete(namespace, ids, filter, delete_all)- Delete vectorsfetch(namespace, ids)- Fetch vectors by IDbatch_query(namespace, queries)- Execute multiple queries
Full-Text Operations
index_documents(namespace, documents)- Index documentsfulltext_search(namespace, query, top_k, filter)- Text searchhybrid_search(namespace, vector, query, alpha, ...)- Hybrid search
Namespace Operations
list_namespaces()- List all namespacesget_namespace(namespace)- Get namespace infocreate_namespace(namespace, dimensions, index_type)- Create namespacedelete_namespace(namespace)- Delete namespace
Admin Operations
health()- Check server healthget_index_stats(namespace)- Get index statisticscompact(namespace)- Trigger compactionflush(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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dakera-0.2.0.tar.gz.
File metadata
- Download URL: dakera-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2b4c185df8a981af9d57e3a2472cb1fe5690f99cff22c82a00037a10c20c3f1
|
|
| MD5 |
fdc0bb33ff5254c3387030b76e5ebbbe
|
|
| BLAKE2b-256 |
c71b630a7a29addda17b39c3fa6f0379f10e6f076d76370e5557e542d1c9f97f
|
Provenance
The following attestation bundles were made for dakera-0.2.0.tar.gz:
Publisher:
release.yml on Dakera-AI/dakera-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dakera-0.2.0.tar.gz -
Subject digest:
e2b4c185df8a981af9d57e3a2472cb1fe5690f99cff22c82a00037a10c20c3f1 - Sigstore transparency entry: 1130648215
- Sigstore integration time:
-
Permalink:
Dakera-AI/dakera-py@8e8ef213b8a89a145c63ba96436041bf0febb4ce -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Dakera-AI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8e8ef213b8a89a145c63ba96436041bf0febb4ce -
Trigger Event:
release
-
Statement type:
File details
Details for the file dakera-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dakera-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3642307ae200633db4f1f7659f5925a907a1acb75e64db206d1248ef2eca049
|
|
| MD5 |
b70d8a535bb4bef7a810bb2cc127b603
|
|
| BLAKE2b-256 |
e5ca4fa50a34c7050c42cfebad709183931b7840e9afc982ab2e8288c4f08cfd
|
Provenance
The following attestation bundles were made for dakera-0.2.0-py3-none-any.whl:
Publisher:
release.yml on Dakera-AI/dakera-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dakera-0.2.0-py3-none-any.whl -
Subject digest:
c3642307ae200633db4f1f7659f5925a907a1acb75e64db206d1248ef2eca049 - Sigstore transparency entry: 1130648260
- Sigstore integration time:
-
Permalink:
Dakera-AI/dakera-py@8e8ef213b8a89a145c63ba96436041bf0febb4ce -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Dakera-AI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8e8ef213b8a89a145c63ba96436041bf0febb4ce -
Trigger Event:
release
-
Statement type: