Skip to main content

Python client for AchillesDB, a vector database

Project description

achillesdb

Python client for AchillesDB, a hybrid vector and document database (WiredTiger + FAISS under the hood).

Install

pip install achillesdb

Requires Python >= 3.10. The client talks to a running AchillesDB server over HTTP, so you'll need one reachable (defaults to localhost:8180).

Quickstart (sync)

from achillesdb import AchillesClient

with AchillesClient(host="localhost", port=8180) as client:
    db = client.create_database("docs")

    collection = db.create_collection("articles")
    collection.add_documents(
        ids=["1", "2"],
        documents=["hello world", "goodbye world"],
        embeddings=[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]],
        metadatas=[{"category": "tech"}, {"category": "food"}],
    )

    results = collection.query(top_k=5, query_embedding=[0.1, 0.2, 0.3])
    print(results)

Quickstart (async)

import asyncio
from achillesdb import AsyncAchillesClient

async def main():
    async with AsyncAchillesClient(host="localhost", port=8180) as client:
        db = await client.create_database("docs")
        collection = await db.create_collection("articles")
        await collection.add_documents(
            ids=["1"],
            documents=["hello world"],
            embeddings=[[0.1, 0.2, 0.3]],
        )
        results = await collection.query(top_k=5, query_embedding=[0.1, 0.2, 0.3])
        print(results)

asyncio.run(main())

Filtering with where

Pass a plain dict shaped like the HTTP API's where field, or use the W builder for a fluent API. Supported operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $arrContains, $and, $or.

from achillesdb import W

collection.query(
    top_k=5,
    query_embedding=[0.1, 0.2, 0.3],
    where=W.and_(W.eq("category", "tech"), W.nin_("year", [2020, 2021])),
)

# equivalent plain-dict form
collection.query(
    top_k=5,
    query_embedding=[0.1, 0.2, 0.3],
    where={"$and": [{"category": "tech"}, {"year": {"$nin": [2020, 2021]}}]},
)

Embedding functions

Pass embedding_function to the client to embed text automatically instead of supplying embeddings/query_embedding yourself:

client = AchillesClient(embedding_function=my_embed_fn)
collection.add_documents(ids=["1"], documents=["hello world"])
collection.query(top_k=5, query="hello")

my_embed_fn takes a list[str] and returns a list[list[float]] (sync or async, matching the client's mode).

Development

cd sdk/python
uv sync
uv run pytest -m unit            # unit + mocked tests, no server required
uv run pytest -m integration     # requires a running AchillesDB server

License

See the repository root for license information.

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

achillesdb-0.1.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

achillesdb-0.1.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: achillesdb-0.1.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.20

File hashes

Hashes for achillesdb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2b6fbd200f25006f61bd1fce420c8cab38ed6686e82ad4fd3fd3c3b2c779a329
MD5 556066f0ee98b000a72cc1a143ee1dd3
BLAKE2b-256 e99fb5e76592eb6ca6201f600b5946dc173e69286e3f1a2059b5130b39af5b2d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: achillesdb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.20

File hashes

Hashes for achillesdb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1cfc3aa1fdd666ddf199fdc182753ce66961b1f96517517b488c3bd047aa3f2
MD5 46dc41ed5cbb4b6e1929f0479942a3bd
BLAKE2b-256 f38f07dcfc787f84b3d84966417c9a13a3dac8f3d7cdd9b4089032b1a14d4f8b

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