Skip to main content

Tencent VectorDB Python Async SDK

Project description

aiotcvectordb — Tencent VectorDB Python Async SDK

CI TestPyPI Publish

An asyncio-first client for Tencent Cloud VectorDB built on top of aiohttp. It mirrors the official tcvectordb SDK’s models and request payloads, while providing non-blocking APIs and REPL-friendly representations.

Looking for Chinese docs? See README_zh.md.

Features

  • Fully async HTTP client using aiohttp with connection pooling and proxy support.
  • Type parity with tcvectordb (indexes, enums, document types) re-exported under aiotcvectordb.model.
  • Convenient async wrappers: AsyncDatabase, AsyncCollection, AsyncCollectionView, AsyncDocumentSet.
  • Supports vector search, hybrid search (dense/sparse), text search with server-side embeddings, and full-text search.

Requirements

  • Python 3.9+
  • Dependencies: tcvectordb, aiohttp, numpy
  • Optional: qcloud_cos for AI document upload in CollectionView.upload/load_and_split_text

Install

pip install aiotcvectordb

From source (repo root):

pip install -e .
# or with uv
uv pip install -e .

Quickstart

import asyncio
from aiotcvectordb import AsyncVectorDBClient
from aiotcvectordb.model import (
    Index, VectorIndex, FilterIndex,
    FieldType, IndexType, MetricType,
)

async def main():
    async with AsyncVectorDBClient(
        url="http://127.0.0.1:8081",
        username="root",
        key="<your-api-key>",
    ) as client:
        # Create database if not exists
        await client.create_database_if_not_exists("demo_db")

        # Define indexes for the collection
        idx = Index()
        idx.add(VectorIndex(
            name="vector",
            dimension=3,
            index_type=IndexType.HNSW,
            metric_type=MetricType.COSINE,
            params={"M": 8, "efConstruction": 80},
        ))
        idx.add(FilterIndex(
            name="id",
            field_type=FieldType.String,
            index_type=IndexType.PRIMARY_KEY,
        ))

        # Create collection if not exists
        await client.create_collection_if_not_exists(
            database_name="demo_db",
            collection_name="demo_coll",
            shard=1,
            replicas=1,
            index=idx,
        )

        # Upsert documents
        docs = [
            {"id": "1", "vector": [0.1, 0.2, 0.3], "tag": "hello"},
            {"id": "2", "vector": [0.2, 0.3, 0.1], "tag": "world"},
        ]
        await client.upsert("demo_db", "demo_coll", documents=docs)

        # Vector similarity search
        res = await client.search(
            database_name="demo_db",
            collection_name="demo_coll",
            vectors=[[0.1, 0.2, 0.3]],
            limit=5,
            retrieve_vector=False,
        )
        print(res)

asyncio.run(main())

Common Operations

  • Databases: create_database, create_database_if_not_exists, drop_database, list_databases
  • Collections: create_collection, create_collection_if_not_exists, describe_collection, list_collections, truncate_collection, set_alias, delete_alias
  • Documents: upsert, query, count, update, delete
  • Search: search, search_by_id, search_by_text (server-side embedding), hybrid_search, fulltext_search

AI Document Database

from aiotcvectordb.model import SplitterProcess

aidb = await client.create_ai_database("ai_demo")
cv = await aidb.create_collection_view(name="cv1")
ds = await cv.load_and_split_text("./doc.pdf", splitter_process=SplitterProcess())
results = await cv.search("your question", limit=5)

Links

License

MIT

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

aiotcvectordb-0.1.1.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

aiotcvectordb-0.1.1-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file aiotcvectordb-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for aiotcvectordb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cbaf4e816180817dfeee1fb01df42141926e3682a7ce1307cafa5cd148d2f80a
MD5 75c21217765ef540827eea33e56fcac4
BLAKE2b-256 0f1fde42142e7a17fb3f892b0e171765a315f2bf68aeb40ea6c854c2e99b1519

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiotcvectordb-0.1.1.tar.gz:

Publisher: release.yml on alviezhang/aiotcvectordb

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

File details

Details for the file aiotcvectordb-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for aiotcvectordb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f921a2dfc94692eb60d3f6f93ee92cd141d6300eee925e1535cb494fc084bc41
MD5 a4c13f5222e9535656385c14b6d10424
BLAKE2b-256 b4a2bee051b370062e0148945dcad06a8b4f44c87e6deee602897f9e3fe4a054

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiotcvectordb-0.1.1-py3-none-any.whl:

Publisher: release.yml on alviezhang/aiotcvectordb

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