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
:globe_with_meridians: A Python wrapper for the Geocodio geolocation service API

Py-Geocodio Python wrapper for Geocodio geocoding API. Full documentation on Read the Docs. If you are upgrading from a version prior to 0.2.0 please

Ben Lopatin 84 Aug 02, 2022
Python client for Toyota North America service API

toyota-na Python client for Toyota North America service API Install pip install toyota-na[qt] [qt] is required for generating authorization code. Us

Gavin Ni 18 Sep 06, 2022
Man-Userbot adalah userbot Telegram modular yang berjalan di Python3 dengan database sqlalchemy

Man-Userbot Telegram Man-Userbot adalah userbot Telegram modular yang berjalan di Python3 dengan database sqlalchemy. Berbasis Paperplane dan ProjectB

DzLyz 1 Feb 12, 2022
Go-cqhttp Plugin for EFB QQ Slave.

efb-qq-plugin-go-cqhttp efb-qq-plugin-go-cqhttp 是 efb-qq-slave 的插件,需要配合 efb-qq-slave 使用,使用前请先阅读 efb-qq-slave 的文档。

XYenon 26 Dec 11, 2022
Framework for Telegram users and chats investigating.

telegram_scan Fantastic and full featured framework for Telegram users and chats investigating. Prerequisites: pip3 install pyrogram; get api_id and a

71 Dec 17, 2022
MusicBot is the original Discord music bot written for Python 3.5+, using the discord.py library

The original MusicBot for Discord (formerly SexualRhinoceros/MusicBot)

Just Some Bots 2.9k Jan 02, 2023
Um simples bot público para todos usarem no discord!

Discord Bot - Código Público Características: Linguagem de Programação: Python Quantidade de comandos: 17 Comandos: Prefixo do bot: O prefixo desse bo

Kevin 3 Dec 31, 2021
Sielzz Music adalah proyek bot musik telegram, memungkinkan Anda memutar musik di telegram grup obrolan suara.

Hi, I am: Requirements 📝 FFmpeg NodeJS nodesource.com Python 3.8 or higher PyTgCalls MongoDB Get STRING_SESSION from below: 🎖 History Features 🔮 Th

1 Nov 29, 2021
A Discord bot to easily and quickly format your JSON data

Invite PrettyJSON to your Discord server Table of contents About the project What is JSON? What is pretty printing? How to use Input options Command I

Sem 4 Jan 24, 2022
Recommendation systems are among most widely preffered marketing strategies.

Recommendation systems are among most widely preffered marketing strategies. Their popularity comes from close prediction scores obtained from relationships of users and items. In this project, two r

Sübeyte 8 Oct 06, 2021
Python-based Snapchat score booster using pyautogui module

Snapchat Snapscore Botter Python-based Snapchat score booster using pyautogui module. Click here to report bugs. Usage Download ZIP here and extract t

477 Dec 31, 2022
AuthGG is a Python library for dealing with Auth.gg apis

AuthGG AuthGG is a Python library for dealing with Auth.gg apis Installation Use the package manager pip to install requests Add the auth.py file in y

ExtremeDev 1 Dec 20, 2021
Messing around with GitHub API to look at omicron build times

gh-workflow-runs This is a very simple tool to dump out basic information about workflow runs for a GitHub repo. The structure is based on gh-subscrip

David Pacheco 1 Nov 30, 2021
A multipurpose, semi-modular Discord bot written in Python with the new discord.py module.

Discord.py Reaction Bot MIRAI KURIYAMA A multipurpose, semi-modular Discord bot written in Python with the new discord.py module. Installing dependenc

1 Dec 02, 2021
Discord bot for calculating basic operations and formulas. (Early Development)

MathBot Discord bot for calculating basic operations and formulas. (Early Development) Commits Feel free to contribute to this bot by forking and pull

4 Jul 14, 2022
This is a open source discord bot project

pythonDiscordBot This is a open source discord bot project #based on the MAX A video: https://www.youtube.com/watch?v=jHZlvRr9KxM Prerequisites Python

Edson Holanda Teixeira Junior 3 Oct 11, 2021
A Python interface to AFL, allowing for easy injection of testcases and other functionality.

Fuzzer This module provides a Python wrapper for interacting with AFL (American Fuzzy Lop: http://lcamtuf.coredump.cx/afl/). It supports starting an A

Shellphish 614 Dec 26, 2022
Intelligent Trading Bot: Automatically generating signals and trading based on machine learning and feature engineering

Intelligent Trading Bot: Automatically generating signals and trading based on machine learning and feature engineering

Alexandr Savinov 326 Jan 03, 2023
Code for generating Tiktok X-Gorgon, X-Khronos and etc. parameters

TikTok-Algorithm I found this python file from a source which was later deleted. Although the test api functions no longer seem to work, surprisingly

0 Dec 09, 2021
Solves bombcrypto newest captcha

Solves Bombcrypto newest captcha A very compact implementation using just cv2 and ctypes, ready to be deployed to your own project. How does it work I

19 May 06, 2022