Skip to main content

Python client for Vektonn

Project description

Python client for Vektonn

CI version Supported Python Versions license

Vektonn is a high-performance battle-tested kNN vector search engine for your data science applications. It helps you manage vectors' lifecycle and radically reduces time to market.

See documentation for more info.

Installation

Install the latest version:

$ pip install vektonn

Install specific version:

$ pip install vektonn==1.2.3

Upgrade to the latest version:

$ pip install --upgrade vektonn

Usage

Having Vektonn running on localhost:8081 and configured for QuickStart examples one can access it with synchronous Python client:

from vektonn import Vektonn

vektonn_client = Vektonn('http://localhost:8081')

or asynchronous one:

from vektonn import VektonnAsync

vektonn_client_async = VektonnAsync('http://localhost:8081')

To upload data to Vektonn use upload() method:

from vektonn.dtos import Attribute, AttributeValue, InputDataPoint, Vector

vektonn_client.upload(
    data_source_name='QuickStart.Source',
    data_source_version='1.0',
    input_data_points=[
        InputDataPoint(
            attributes=[
                Attribute(key='id', value=AttributeValue(int64=1)),
                Attribute(key='payload', value=AttributeValue(string='sample data point')),
            ],
            vector=Vector(is_sparse=False, coordinates=[3.14, 2.71]))
    ])

To query Vektonn for k nearest data points to the given query_vector use search() method:

from vektonn.dtos import Vector, SearchQuery

k = 10
query_vector = Vector(is_sparse=False, coordinates=[1.2, 3.4])

search_results = vektonn_client.search(
    index_name='QuickStart.Index',
    index_version='1.0',
    search_query=SearchQuery(k=k, query_vectors=[query_vector]))

print(f'For query vector {query_vector.coordinates} {k} nearest data points are:')
for fdp in search_results[0].nearest_data_points:
    attrs = {x.key: x.value for x in fdp.attributes}
    distance, vector, dp_id, payload = fdp.distance, fdp.vector, attrs['id'].int64, attrs['payload'].string
    print(f' - "{payload}" with id = {dp_id}, vector = {vector.coordinates}, distance = {distance}')

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

vektonn-0.7.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

vektonn-0.7.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file vektonn-0.7.1.tar.gz.

File metadata

  • Download URL: vektonn-0.7.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for vektonn-0.7.1.tar.gz
Algorithm Hash digest
SHA256 8ad403b777edb5e7a06c46e1b6ab7b55d9eb497113bd02544dd69faeeddc5994
MD5 827b9706883141220642699272f3c7f4
BLAKE2b-256 91a1b77bed582ad7cc3695bb4eccb5a59191616dfe0b5fdcc726336185986c50

See more details on using hashes here.

File details

Details for the file vektonn-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: vektonn-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for vektonn-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a041d2407c400ca758f53bc6241f4f0128a0d14aeedbcc10e732f1cc1fa2e8b
MD5 9869adac355156139e5412a8274e8bf7
BLAKE2b-256 e9f15f650f8b4fbb5d83fd719fd745754a6b29390bbffb2e7d48873c86898c63

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