Skip to main content

memvectordb python client.

Project description

memvectorDB-python client

Getting Started

pip install memvectordb-python

To Initialize the Client

from memvectordb.collection import Collection

client = MemVectorDB(base_url = "base-url") # default http://127.0.0.1:8000

To Create Collection

# To create a new collection
collection_name = "collection_name"
dimension = "dimension-of-vectors-to-be-stored"
distance = "distance-metric" # either 'cosine', 'euclidean' or 'dot'
collection = client.create_collection(collection_name, dimension, distance)

To Get Collection

collection_name = "collection_name"
collection = client.get_collection(collection_name)

To Delete collection

collection_name = "collection_name"
collection = client.delete_collection(collection_name)

To Insert Vectors(streaming)

collection_name = "collection_name"
embedding = {
    "id": "1",
    "vector": [0.14, 0.316, 0.433],
    "metadata": {
        "key1": "value1",
        "key2": "value2"
    }
}

client.insert_embeddings(
    collection_name=collection_name, 
    vector_id=embedding["id"], 
    vector=embedding["vector"], 
    metadata=embedding["metadata"]
)

To Insert Vectors(batch)

collection_name = "collection_name"
embeddings = [
    {
        "id": "1",
        "vector": [0.14, 0.316, 0.433],
        "metadata": {
            "key1": "value1",
            "key2": "value2"
        }
    },
    {
        "id": "2",
        "vector": [0.27, 0.531, 0.621],
        "metadata": {
            "key1": "value3",
            "key2": "value4"
        }
    }
]

for embedding in embeddings:
    client.batch_insert_embeddings(
        collection_name=collection_name, 
        vector_id=embedding["id"], 
        vector=embedding["vector"], 
        metadata=embedding["metadata"]
    )

To Query Vectors.

k = "number-of-items-to query"
collection_name = "collection_name"
query_vector = "query_vector"

# example of query_vector: [0.32654, 0.24423, 0.7655] 
# ensure the dimensions match the collection's dimensions
client.get_similarity(collection_name, k, query_vector)

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

memvectordb_python-0.0.2.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

memvectordb_python-0.0.2-py2.py3-none-any.whl (3.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file memvectordb_python-0.0.2.tar.gz.

File metadata

  • Download URL: memvectordb_python-0.0.2.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for memvectordb_python-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4d73abd19f9240e829bfce53a347c2c8e135152280593f717c9ac0dfbf91e5ab
MD5 4139a96da5f399fed4a86e52ef4d31ce
BLAKE2b-256 32d427ab5e26218d1dfa64ec1c7aa9b6a411bcc224bd0fdb20d3c035ae41e54f

See more details on using hashes here.

File details

Details for the file memvectordb_python-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for memvectordb_python-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 672161113c9ebb6518868a13024d54111b7b8817bb085015d099416e7b1b1a60
MD5 8f7c4ba5670900ffab401926004b25a4
BLAKE2b-256 3cc5f1a94449138fe25e4df19868198258b19df99d0cf453ff7ce87daacbade3

See more details on using hashes here.

Supported by

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