Python client for Vektonn

Overview

Python client for Vektonn

CI version Supported Python Versions license

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 AttributeDto, AttributeValueDto, InputDataPointDto, VectorDto

vektonn_client.upload(
    data_source_name='QuickStart.Source',
    data_source_version='1.0',
    input_data_points=[
        InputDataPointDto(
            attributes=[
                AttributeDto(key='id', value=AttributeValueDto(int64=1)),
                AttributeDto(key='payload', value=AttributeValueDto(string='sample data point')),
            ],
            vector=VectorDto(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 VectorDto, SearchQueryDto

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

search_results = vektonn_client.search(
    index_name='QuickStart.Index',
    index_version='1.0',
    search_query=SearchQueryDto(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}')
You might also like...
Python Client for Instagram API

This project is not actively maintained. Proceed at your own risk! python-instagram A Python 2/3 client for the Instagram REST and Search APIs Install

The official Python client library for the Kite Connect trading APIs

The Kite Connect API Python client - v3 The official Python client for communicating with the Kite Connect API. Kite Connect is a set of REST-like API

A Python Client for News API

newsapi-python A Python client for the News API. License Provided under MIT License by Matt Lisivick. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRAN

SmartFile API Client (Python).
SmartFile API Client (Python).

A SmartFile Open Source project. Read more about how SmartFile uses and contributes to Open Source software. Summary This library includes two API cli

Python client for the Socrata Open Data API

sodapy sodapy is a python client for the Socrata Open Data API. Installation You can install with pip install sodapy. If you want to install from sour

Python client for the Echo Nest API
Python client for the Echo Nest API

Pyechonest Tap into The Echo Nest's Musical Brain for the best music search, information, recommendations and remix tools on the web. Pyechonest is an

A Python Tumblr API v2 Client

PyTumblr Installation Install via pip: $ pip install pytumblr Install from source: $ git clone https://github.com/tumblr/pytumblr.git $ cd pytumblr $

A super awesome Twitter API client for Python.

birdy birdy is a super awesome Twitter API client for Python in just a little under 400 LOC. TL;DR Features Future proof dynamic API with full REST an

Unirest in Python: Simplified, lightweight HTTP client library.

Unirest for Python Unirest is a set of lightweight HTTP libraries available in multiple languages, built and maintained by Mashape, who also maintain

Comments
  • Optimize DTOs json serialization

    Optimize DTOs json serialization

    test_perf_serialize run shows that VektonnBaseModel.json() is a huge bottleneck:

    ----------------------------- Captured stdout call -----------------------------
             28285893 function calls in 25.275 seconds
    
       Ordered by: internal time
    
       ncalls  tottime  percall  cumtime  percall filename:lineno(function)
       118351   15.430    0.000   21.607    0.000 dtos.py:17(json)
       118351    3.108    0.000    3.522    0.000 test_dtos_perf.py:55(to_idp_fast)
     12781908    2.509    0.000    2.509    0.000 {built-in method _abc._abc_instancecheck}
     12781908    2.122    0.000    4.630    0.000 abc.py:96(__instancecheck__)
       118351    0.691    0.000    0.691    0.000 {orjson.dumps}
       118351    0.414    0.000    0.414    0.000 {method 'tolist' of 'numpy.ndarray' objects}
       118351    0.189    0.000    0.552    0.000 typing.py:802(__getitem__)
       118351    0.130    0.000    0.317    0.000 typing.py:255(inner)
       236702    0.113    0.000    0.1[65](https://github.com/vektonn/vektonn-client-python/runs/5082861448?check_suite_focus=true#step:6:65)    0.000 <frozen importlib._bootstrap>:389(parent)
       118351    0.076    0.000    0.815    0.000 utils.py:13(orjson_dumps)
       23[67](https://github.com/vektonn/vektonn-client-python/runs/5082861448?check_suite_focus=true#step:6:67)02    0.075    0.000    0.104    0.000 typing.py:329(__hash__)
            1    0.071    0.071    3.605    3.605 test_dtos_perf.py:42(construct)
            1    0.063    0.063   21.671   21.671 test_dtos_perf.py:37(serialize)
       118351    0.059    0.000    0.083    0.000 typing.py:720(__hash__)
       355053    0.052    0.000    0.052    0.000 {built-in method builtins.hash}
       236[70](https://github.com/vektonn/vektonn-client-python/runs/5082861448?check_suite_focus=true#step:6:70)2    0.051    0.000    0.051    0.000 {method 'rpartition' of 'str' objects}
       11[83](https://github.com/vektonn/vektonn-client-python/runs/5082861448?check_suite_focus=true#step:6:83)51    0.047    0.000    0.047    0.000 {method 'decode' of 'bytes' objects}
       236702    0.027    0.000    0.027    0.000 {built-in method builtins.isinstance}
       118351    0.019    0.000    0.019    0.000 {built-in method builtins.len}
       118351    0.016    0.000    0.016    0.000 typing.py:1149(cast)
       118351    0.012    0.000    0.012    0.000 {method 'append' of 'list' objects}
            1    0.000    0.000    0.000    0.000 cProfile.py:133(__exit__)
            1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
    
    help wanted 
    opened by AndrewKostousov 2
Releases(v0.7.1)
  • v0.7.1(Feb 25, 2022)

    • Speed up VektonnBaseModel.json() for Vector model (see #3)

    Full Changelog: https://github.com/vektonn/vektonn-client-python/compare/v0.7.0...v0.7.1

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Feb 25, 2022)

    • Allow to specify request timeouts
    • Introduce retrieveVectors parameter to speed things up when there is no need in nearest vectors themselves

    Full Changelog: https://github.com/vektonn/vektonn-client-python/compare/v0.6.0...v0.7.0

    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Jan 19, 2022)

    What's Changed

    • Remove 'Dto' suffix form DTOs' names by @streamoverflow in https://github.com/vektonn/vektonn-client-python/pull/2

    New Contributors

    • @streamoverflow made their first contribution in https://github.com/vektonn/vektonn-client-python/pull/2

    Full Changelog: https://github.com/vektonn/vektonn-client-python/compare/v0.5.4...v0.6.0

    Source code(tar.gz)
    Source code(zip)
  • v0.5.4(Nov 23, 2021)

  • v0.5.3(Nov 23, 2021)

  • v0.5.2(Nov 23, 2021)

  • v0.5.1(Nov 23, 2021)

    • Support attribute values with floating-point numeric data type

    Full Changelog: https://github.com/vektonn/vektonn-client-python/compare/v0.5.0...v0.5.1

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Nov 23, 2021)

Owner
Vektonn
An open source vector search solution
Vektonn
Want to play What Would Rather on your Server? Invite the bot now!😏

What is this Bot? πŸ‘€ What You Would Rather? is a Guessing game where you guess one thing. Long Description short Take this example: You typed r!rather

δΈ‚γ„šδΉˆδΉ™γƒ„ 2 Nov 17, 2021
πŸ‘Ύ Telegram Smart Group Assistant πŸ€–

DarkHelper πŸŒ– Features ⚑️ Smart anti-apam & anti-NFSW message checker Tag Members , Entertain facility , Welcommer ban , unban , mute , unmute , lock

amirali rajabi 38 Dec 18, 2022
A simple Python API wrapper for Cloudflare Stream's API.

python-cloudflare-stream A basic Python API wrapper for working with Cloudflare Stream. Arbington.com started off using Cloudflare Stream. We used the

Arbington 3 Sep 08, 2022
Library to manage your own custom RPC on your desktop

Info I don't recommend novices setting this up yourself. It requires Redis, a server to host the API on, and a bit of understanding of Windows & Pytho

Isaac K 1 Apr 16, 2022
Telegram bot to stream videos in telegram voicechat for both groups and channels.

Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live streams, YouTube videos and telegram media. With record stream support, Schedule streams, and many more

SOCIAL MECHANIC 4 Nov 13, 2022
Wakatime Response In javascript and python

Project Title Wakatime Response In javascript and python Description just for refrence Getting Started Dependencies For Python: requests json For Java

Gjenius20 1 Dec 31, 2021
Starlink Order Status Notification

Starlink Order Status Notification This script logs into Starlink order portal, pulls your estimated delivery date and emails it to a designated email

Aaron R. 1 Jul 08, 2022
ignorant allows you to check if a phone number is used on different sites like snapchat, instagram.

Ignorant For BTC Donations : 1FHDM49QfZX6pJmhjLE5tB2K6CaTLMZpXZ ignorant does not alert the target phone number ignorant allows you to check if a phon

Palenath 513 Dec 31, 2022
A Telegram bot to all media and documents files to web link .

FileStreamBot A Telegram bot to all media and documents files to web link . Report a Bug | Request Feature 🍁 About This Bot : This bot will give you

Code X Mania 129 Jan 03, 2023
WatonAPI is an API used to connect to spigot servers with the WatonPlugin to communicate.

WatonAPI is an API used to connect to spigot servers with the WatonPlugin to communicate. You can send messages to the server and read messages, making it useful for cross-chat programs.

Waton 1 Nov 22, 2021
TFT Bot that automatically surrenders and allows finishing TFT Passes easily.

Image Based TFT Bot TFT Bot that automatically surrenders and allows finishing TFT Passes easily. Please read full file! You can check new releases he

1 Feb 06, 2022
Python SDK for IEX Cloud

iexfinance Python SDK for IEX Cloud. Architecture mirrors that of the IEX Cloud API (and its documentation). An easy-to-use toolkit to obtain data for

Addison Lynch 640 Jan 07, 2023
Telegram File Renamer Bot

RENAMER_BOT Telegram File Renamer Bot Configs TG_BOT_TOKEN - Get bot token from @BotFather API_ID - From my.telegram.org API_HASH - From my.telegram.o

Lntechnical 37 Dec 27, 2022
Minimal telegram voice chat music bot, in pyrogram.

VCBOT Fully working VC (user)Bot, based on py-tgcalls and py-tgcalls-wrapper with minimal features. Deploying To heroku: Local machine/VPS: git clone

Aditya 33 Nov 12, 2022
Exchange indicators & Basic functions for Binance API.

binance-ema Exchange indicators & Basic functions for Binance API. This python library has been written to calculate SMA, EMA, MACD etc. functions wit

Emre MENTEŞE 24 Jan 06, 2023
this is an op music pyrogram music bot.

amanrajputpytgcallmusic this is an op music pyrogram music bot..... this bot user music bot can play music without being admin...... TG-MusicPlayer A

2 Dec 27, 2021
Modified Version of mega.py package for Pyrogram Bots

Pyro Mega.py Python library for the Mega.co.nz API, currently supporting: login uploading downloading deleting searching sharing renaming moving files

I'm Not A Bot #Left_TG 10 Aug 03, 2022
Using Streamlit to build a simple UI on top of the OpenSea API

OpenSea API Explorer Using Streamlit to build a simple UI on top of the OpenSea API. 🀝 Contributing Contributions, issues and feature requests are we

Gavin Capriola 1 Jan 04, 2022
Bulk convert image types with Python

Bulk Image Converter πŸ”₯ Helper script to convert a folder's worth of images from one filetype to another, and optionally delete originals Use Setup /

1 Nov 13, 2021
Salmanul Farisx Bot With Python

Salman_Farisx_Bot How To Deploy Video Subscribe YouTube Channel Added Features Imdb posters for autofilter. Imdb rating for autofilter. Custom caption

1 Dec 23, 2021