Skip to main content

Python SDK for AkiDB — a Mac-native retrieval memory engine for private AI agents

Project description

AkiDB Python SDK

A typed, production-grade Python client for AkiDB — a Mac-native retrieval memory engine for private AI agents.

Install

pip install -e ".[dev]"   # from sdks/python

Usage

from akidb import AkiDBClient

with AkiDBClient(
    "localhost:50051",
    timeout=5.0,          # per-call deadline (seconds)
    max_retries=3,        # retries on transient errors, exponential backoff
    tls=True,             # TLS channel
    auth_token="…",       # sent as `authorization: Bearer …`
) as client:
    client.insert("doc-1", embedding, text="the source text", metadata=b'{"lang":"en"}')

    result = client.text_search(
        "why does token refresh fail?",
        top_k=5, hybrid=True, rerank=True, diversity=True, pack=True, token_budget=1024,
    )
    for hit in result:
        print(hit.id, hit.score)
    print(result.context_pack)

Async

from akidb.aio import AsyncAkiDBClient

async with AsyncAkiDBClient("localhost:50051") as client:
    await client.insert("doc-1", embedding, text="hello")
    result = await client.text_search("hello", hybrid=True, pack=True)

Agent memory

client.memory_write("m1", embedding, "remember this", kind="note", conversation_id="c1")
hits = client.memory_read(query_embedding, conversation_id="c1")

Features

  • Per-call deadlines, retry with exponential backoff on transient codes (UNAVAILABLE, DEADLINE_EXCEEDED, RESOURCE_EXHAUSTED).
  • TLS + bearer-token auth; custom channel options and metadata.
  • Typed errors (NotFoundError, InvalidArgumentError, UnavailableError, …) mapped from gRPC status codes; see akidb.errors.
  • Full RPC coverage: insert, insert_batch, update, get, delete, search, search_batch, text_search, health, cluster_state, plus memory_write/read.
  • Sync (AkiDBClient) and async (AsyncAkiDBClient) clients.

Tests

pytest tests/ -v

Unit tests mock the gRPC stub, so no running server is required. A live integration test (tests/test_live.py) runs only when AKIDB_SERVER_ADDR is set (with AKIDB_TEST_DIM matching the server's index dimension); it is exercised in CI (.github/workflows/sdks.yml) against a real server.

Observability & resilience knobs

timeout, max_retries, retry_backoff (jittered), on_retry=(attempt, error), tls/ca_cert, auth_token, metadata, and gRPC interceptors are all constructor options on both AkiDBClient and AsyncAkiDBClient.

Regenerating gRPC stubs / proto drift

The committed akidb/akidb_pb2*.py are generated from the vendored proto/akidb.proto (a copy of crates/grpc-server/proto/akidb.proto):

python -m grpc_tools.protoc -I proto \
  --python_out=akidb --grpc_python_out=akidb proto/akidb.proto
# then make the grpc import relative: `from . import akidb_pb2 as akidb__pb2`

../check-proto-drift.sh (and test_proto_drift.py) fail if the vendored proto drifts from the canonical engine proto.

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

akidb-0.6.1.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

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

akidb-0.6.1-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file akidb-0.6.1.tar.gz.

File metadata

  • Download URL: akidb-0.6.1.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for akidb-0.6.1.tar.gz
Algorithm Hash digest
SHA256 ce5f3f7b858e2266362f1947ae87e9f9f5d3859e40b56f5d20e2408a8753e654
MD5 ea51608c71430e747bbbe545b2312e8c
BLAKE2b-256 f95d987ed077b5959b710cc363b0cdff95c146a6098cad9238919ae0b1595c7b

See more details on using hashes here.

File details

Details for the file akidb-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: akidb-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for akidb-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f12385c7915ed96ac2e062f03994d52b19a569455244fe0cc05d6f64641b0f95
MD5 fc9d2e0b1f3a3bfe3f536628613f3207
BLAKE2b-256 e004f8c30b36a4582e4771dc2b7e31ea38938d65b6f607352b6b4d721b249481

See more details on using hashes here.

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