update interface and version for fastembed (#340)

* update interface and version for fastembed

* fix types

* fix types

* regen async

* use python 3.11 to check compatibility

* fix docstring

* regen async

* propagate batch size
This commit is contained in:
Andrey Vasnetsov
2023-10-16 18:13:52 +02:00
committed by generall
parent 2a07215787
commit 0cfc45a340
13 changed files with 380 additions and 203 deletions

View File

@@ -39,7 +39,7 @@ jobs:
poetry install --no-interaction --no-ansi --all-extras
- name: Run async client generation tests
run: |
if [[ ${{ matrix.python-version }} == "3.9.x" ]]; then
if [[ ${{ matrix.python-version }} == "3.11.x" ]]; then
./tests/async-client-consistency-check.sh
fi
shell: bash

View File

@@ -1,7 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.9
python: python3.11
exclude: 'qdrant_client/(grpc|http|models)/'

196
poetry.lock generated
View File

@@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand.
[[package]]
name = "alabaster"
@@ -365,13 +365,13 @@ test = ["pytest (>=6)"]
[[package]]
name = "fastembed"
version = "0.0.5"
version = "0.1.1"
description = "Fast, light, accurate library built for retrieval embedding generation"
optional = true
python-versions = ">=3.8.0,<3.12"
files = [
{file = "fastembed-0.0.5-py3-none-any.whl", hash = "sha256:dd2f89c7e77a47f1de5d77a6fda0a24c4659f25bd95eb08b6429b28c86d12f37"},
{file = "fastembed-0.0.5.tar.gz", hash = "sha256:dca558d358b3fec5f79ce55bb693bc1812f24eb96ab36b6aed6cad395f3eef01"},
{file = "fastembed-0.1.1-py3-none-any.whl", hash = "sha256:131413ae52cd72f4c8cced7a675f8269dbfd1a852abade3c815e265114bcc05a"},
{file = "fastembed-0.1.1.tar.gz", hash = "sha256:f7e524ee4f74bb8aad16be5b687d1f77f608d40e96e292c87881dc36baf8f4c7"},
]
[package.dependencies]
@@ -797,38 +797,38 @@ tests = ["pytest (>=4.6)"]
[[package]]
name = "mypy"
version = "1.5.1"
version = "1.6.0"
description = "Optional static typing for Python"
optional = false
python-versions = ">=3.8"
files = [
{file = "mypy-1.5.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f33592ddf9655a4894aef22d134de7393e95fcbdc2d15c1ab65828eee5c66c70"},
{file = "mypy-1.5.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:258b22210a4a258ccd077426c7a181d789d1121aca6db73a83f79372f5569ae0"},
{file = "mypy-1.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9ec1f695f0c25986e6f7f8778e5ce61659063268836a38c951200c57479cc12"},
{file = "mypy-1.5.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:abed92d9c8f08643c7d831300b739562b0a6c9fcb028d211134fc9ab20ccad5d"},
{file = "mypy-1.5.1-cp310-cp310-win_amd64.whl", hash = "sha256:a156e6390944c265eb56afa67c74c0636f10283429171018446b732f1a05af25"},
{file = "mypy-1.5.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6ac9c21bfe7bc9f7f1b6fae441746e6a106e48fc9de530dea29e8cd37a2c0cc4"},
{file = "mypy-1.5.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:51cb1323064b1099e177098cb939eab2da42fea5d818d40113957ec954fc85f4"},
{file = "mypy-1.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:596fae69f2bfcb7305808c75c00f81fe2829b6236eadda536f00610ac5ec2243"},
{file = "mypy-1.5.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:32cb59609b0534f0bd67faebb6e022fe534bdb0e2ecab4290d683d248be1b275"},
{file = "mypy-1.5.1-cp311-cp311-win_amd64.whl", hash = "sha256:159aa9acb16086b79bbb0016145034a1a05360626046a929f84579ce1666b315"},
{file = "mypy-1.5.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f6b0e77db9ff4fda74de7df13f30016a0a663928d669c9f2c057048ba44f09bb"},
{file = "mypy-1.5.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:26f71b535dfc158a71264e6dc805a9f8d2e60b67215ca0bfa26e2e1aa4d4d373"},
{file = "mypy-1.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2fc3a600f749b1008cc75e02b6fb3d4db8dbcca2d733030fe7a3b3502902f161"},
{file = "mypy-1.5.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:26fb32e4d4afa205b24bf645eddfbb36a1e17e995c5c99d6d00edb24b693406a"},
{file = "mypy-1.5.1-cp312-cp312-win_amd64.whl", hash = "sha256:82cb6193de9bbb3844bab4c7cf80e6227d5225cc7625b068a06d005d861ad5f1"},
{file = "mypy-1.5.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4a465ea2ca12804d5b34bb056be3a29dc47aea5973b892d0417c6a10a40b2d65"},
{file = "mypy-1.5.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:9fece120dbb041771a63eb95e4896791386fe287fefb2837258925b8326d6160"},
{file = "mypy-1.5.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d28ddc3e3dfeab553e743e532fb95b4e6afad51d4706dd22f28e1e5e664828d2"},
{file = "mypy-1.5.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:57b10c56016adce71fba6bc6e9fd45d8083f74361f629390c556738565af8eeb"},
{file = "mypy-1.5.1-cp38-cp38-win_amd64.whl", hash = "sha256:ff0cedc84184115202475bbb46dd99f8dcb87fe24d5d0ddfc0fe6b8575c88d2f"},
{file = "mypy-1.5.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8f772942d372c8cbac575be99f9cc9d9fb3bd95c8bc2de6c01411e2c84ebca8a"},
{file = "mypy-1.5.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:5d627124700b92b6bbaa99f27cbe615c8ea7b3402960f6372ea7d65faf376c14"},
{file = "mypy-1.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:361da43c4f5a96173220eb53340ace68cda81845cd88218f8862dfb0adc8cddb"},
{file = "mypy-1.5.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:330857f9507c24de5c5724235e66858f8364a0693894342485e543f5b07c8693"},
{file = "mypy-1.5.1-cp39-cp39-win_amd64.whl", hash = "sha256:c543214ffdd422623e9fedd0869166c2f16affe4ba37463975043ef7d2ea8770"},
{file = "mypy-1.5.1-py3-none-any.whl", hash = "sha256:f757063a83970d67c444f6e01d9550a7402322af3557ce7630d3c957386fa8f5"},
{file = "mypy-1.5.1.tar.gz", hash = "sha256:b031b9601f1060bf1281feab89697324726ba0c0bae9d7cd7ab4b690940f0b92"},
{file = "mypy-1.6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:091f53ff88cb093dcc33c29eee522c087a438df65eb92acd371161c1f4380ff0"},
{file = "mypy-1.6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:eb7ff4007865833c470a601498ba30462b7374342580e2346bf7884557e40531"},
{file = "mypy-1.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49499cf1e464f533fc45be54d20a6351a312f96ae7892d8e9f1708140e27ce41"},
{file = "mypy-1.6.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4c192445899c69f07874dabda7e931b0cc811ea055bf82c1ababf358b9b2a72c"},
{file = "mypy-1.6.0-cp310-cp310-win_amd64.whl", hash = "sha256:3df87094028e52766b0a59a3e46481bb98b27986ed6ded6a6cc35ecc75bb9182"},
{file = "mypy-1.6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3c8835a07b8442da900db47ccfda76c92c69c3a575872a5b764332c4bacb5a0a"},
{file = "mypy-1.6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:24f3de8b9e7021cd794ad9dfbf2e9fe3f069ff5e28cb57af6f873ffec1cb0425"},
{file = "mypy-1.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:856bad61ebc7d21dbc019b719e98303dc6256cec6dcc9ebb0b214b81d6901bd8"},
{file = "mypy-1.6.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:89513ddfda06b5c8ebd64f026d20a61ef264e89125dc82633f3c34eeb50e7d60"},
{file = "mypy-1.6.0-cp311-cp311-win_amd64.whl", hash = "sha256:9f8464ed410ada641c29f5de3e6716cbdd4f460b31cf755b2af52f2d5ea79ead"},
{file = "mypy-1.6.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:971104bcb180e4fed0d7bd85504c9036346ab44b7416c75dd93b5c8c6bb7e28f"},
{file = "mypy-1.6.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ab98b8f6fdf669711f3abe83a745f67f50e3cbaea3998b90e8608d2b459fd566"},
{file = "mypy-1.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a69db3018b87b3e6e9dd28970f983ea6c933800c9edf8c503c3135b3274d5ad"},
{file = "mypy-1.6.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:dccd850a2e3863891871c9e16c54c742dba5470f5120ffed8152956e9e0a5e13"},
{file = "mypy-1.6.0-cp312-cp312-win_amd64.whl", hash = "sha256:f8598307150b5722854f035d2e70a1ad9cc3c72d392c34fffd8c66d888c90f17"},
{file = "mypy-1.6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:fea451a3125bf0bfe716e5d7ad4b92033c471e4b5b3e154c67525539d14dc15a"},
{file = "mypy-1.6.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e28d7b221898c401494f3b77db3bac78a03ad0a0fff29a950317d87885c655d2"},
{file = "mypy-1.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e4b7a99275a61aa22256bab5839c35fe8a6887781862471df82afb4b445daae6"},
{file = "mypy-1.6.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:7469545380dddce5719e3656b80bdfbb217cfe8dbb1438532d6abc754b828fed"},
{file = "mypy-1.6.0-cp38-cp38-win_amd64.whl", hash = "sha256:7807a2a61e636af9ca247ba8494031fb060a0a744b9fee7de3a54bed8a753323"},
{file = "mypy-1.6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d2dad072e01764823d4b2f06bc7365bb1d4b6c2f38c4d42fade3c8d45b0b4b67"},
{file = "mypy-1.6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b19006055dde8a5425baa5f3b57a19fa79df621606540493e5e893500148c72f"},
{file = "mypy-1.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:31eba8a7a71f0071f55227a8057468b8d2eb5bf578c8502c7f01abaec8141b2f"},
{file = "mypy-1.6.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8e0db37ac4ebb2fee7702767dfc1b773c7365731c22787cb99f507285014fcaf"},
{file = "mypy-1.6.0-cp39-cp39-win_amd64.whl", hash = "sha256:c69051274762cccd13498b568ed2430f8d22baa4b179911ad0c1577d336ed849"},
{file = "mypy-1.6.0-py3-none-any.whl", hash = "sha256:9e1589ca150a51d9d00bb839bfeca2f7a04f32cd62fad87a847bc0818e15d7dc"},
{file = "mypy-1.6.0.tar.gz", hash = "sha256:4f3d27537abde1be6d5f2c96c29a454da333a2a271ae7d5bc7110e6d4b7beb3f"},
]
[package.dependencies]
@@ -905,43 +905,43 @@ files = [
[[package]]
name = "numpy"
version = "1.26.0"
version = "1.26.1"
description = "Fundamental package for array computing in Python"
optional = false
python-versions = "<3.13,>=3.9"
files = [
{file = "numpy-1.26.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f8db2f125746e44dce707dd44d4f4efeea8d7e2b43aace3f8d1f235cfa2733dd"},
{file = "numpy-1.26.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0621f7daf973d34d18b4e4bafb210bbaf1ef5e0100b5fa750bd9cde84c7ac292"},
{file = "numpy-1.26.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:51be5f8c349fdd1a5568e72713a21f518e7d6707bcf8503b528b88d33b57dc68"},
{file = "numpy-1.26.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:767254ad364991ccfc4d81b8152912e53e103ec192d1bb4ea6b1f5a7117040be"},
{file = "numpy-1.26.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:436c8e9a4bdeeee84e3e59614d38c3dbd3235838a877af8c211cfcac8a80b8d3"},
{file = "numpy-1.26.0-cp310-cp310-win32.whl", hash = "sha256:c2e698cb0c6dda9372ea98a0344245ee65bdc1c9dd939cceed6bb91256837896"},
{file = "numpy-1.26.0-cp310-cp310-win_amd64.whl", hash = "sha256:09aaee96c2cbdea95de76ecb8a586cb687d281c881f5f17bfc0fb7f5890f6b91"},
{file = "numpy-1.26.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:637c58b468a69869258b8ae26f4a4c6ff8abffd4a8334c830ffb63e0feefe99a"},
{file = "numpy-1.26.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:306545e234503a24fe9ae95ebf84d25cba1fdc27db971aa2d9f1ab6bba19a9dd"},
{file = "numpy-1.26.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c6adc33561bd1d46f81131d5352348350fc23df4d742bb246cdfca606ea1208"},
{file = "numpy-1.26.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e062aa24638bb5018b7841977c360d2f5917268d125c833a686b7cbabbec496c"},
{file = "numpy-1.26.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:546b7dd7e22f3c6861463bebb000646fa730e55df5ee4a0224408b5694cc6148"},
{file = "numpy-1.26.0-cp311-cp311-win32.whl", hash = "sha256:c0b45c8b65b79337dee5134d038346d30e109e9e2e9d43464a2970e5c0e93229"},
{file = "numpy-1.26.0-cp311-cp311-win_amd64.whl", hash = "sha256:eae430ecf5794cb7ae7fa3808740b015aa80747e5266153128ef055975a72b99"},
{file = "numpy-1.26.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:166b36197e9debc4e384e9c652ba60c0bacc216d0fc89e78f973a9760b503388"},
{file = "numpy-1.26.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f042f66d0b4ae6d48e70e28d487376204d3cbf43b84c03bac57e28dac6151581"},
{file = "numpy-1.26.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e5e18e5b14a7560d8acf1c596688f4dfd19b4f2945b245a71e5af4ddb7422feb"},
{file = "numpy-1.26.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f6bad22a791226d0a5c7c27a80a20e11cfe09ad5ef9084d4d3fc4a299cca505"},
{file = "numpy-1.26.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4acc65dd65da28060e206c8f27a573455ed724e6179941edb19f97e58161bb69"},
{file = "numpy-1.26.0-cp312-cp312-win32.whl", hash = "sha256:bb0d9a1aaf5f1cb7967320e80690a1d7ff69f1d47ebc5a9bea013e3a21faec95"},
{file = "numpy-1.26.0-cp312-cp312-win_amd64.whl", hash = "sha256:ee84ca3c58fe48b8ddafdeb1db87388dce2c3c3f701bf447b05e4cfcc3679112"},
{file = "numpy-1.26.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4a873a8180479bc829313e8d9798d5234dfacfc2e8a7ac188418189bb8eafbd2"},
{file = "numpy-1.26.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:914b28d3215e0c721dc75db3ad6d62f51f630cb0c277e6b3bcb39519bed10bd8"},
{file = "numpy-1.26.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c78a22e95182fb2e7874712433eaa610478a3caf86f28c621708d35fa4fd6e7f"},
{file = "numpy-1.26.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:86f737708b366c36b76e953c46ba5827d8c27b7a8c9d0f471810728e5a2fe57c"},
{file = "numpy-1.26.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:b44e6a09afc12952a7d2a58ca0a2429ee0d49a4f89d83a0a11052da696440e49"},
{file = "numpy-1.26.0-cp39-cp39-win32.whl", hash = "sha256:5671338034b820c8d58c81ad1dafc0ed5a00771a82fccc71d6438df00302094b"},
{file = "numpy-1.26.0-cp39-cp39-win_amd64.whl", hash = "sha256:020cdbee66ed46b671429c7265cf00d8ac91c046901c55684954c3958525dab2"},
{file = "numpy-1.26.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:0792824ce2f7ea0c82ed2e4fecc29bb86bee0567a080dacaf2e0a01fe7654369"},
{file = "numpy-1.26.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7d484292eaeb3e84a51432a94f53578689ffdea3f90e10c8b203a99be5af57d8"},
{file = "numpy-1.26.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:186ba67fad3c60dbe8a3abff3b67a91351100f2661c8e2a80364ae6279720299"},
{file = "numpy-1.26.0.tar.gz", hash = "sha256:f93fc78fe8bf15afe2b8d6b6499f1c73953169fad1e9a8dd086cdff3190e7fdf"},
{file = "numpy-1.26.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:82e871307a6331b5f09efda3c22e03c095d957f04bf6bc1804f30048d0e5e7af"},
{file = "numpy-1.26.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cdd9ec98f0063d93baeb01aad472a1a0840dee302842a2746a7a8e92968f9575"},
{file = "numpy-1.26.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d78f269e0c4fd365fc2992c00353e4530d274ba68f15e968d8bc3c69ce5f5244"},
{file = "numpy-1.26.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8ab9163ca8aeb7fd32fe93866490654d2f7dda4e61bc6297bf72ce07fdc02f67"},
{file = "numpy-1.26.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:78ca54b2f9daffa5f323f34cdf21e1d9779a54073f0018a3094ab907938331a2"},
{file = "numpy-1.26.1-cp310-cp310-win32.whl", hash = "sha256:d1cfc92db6af1fd37a7bb58e55c8383b4aa1ba23d012bdbba26b4bcca45ac297"},
{file = "numpy-1.26.1-cp310-cp310-win_amd64.whl", hash = "sha256:d2984cb6caaf05294b8466966627e80bf6c7afd273279077679cb010acb0e5ab"},
{file = "numpy-1.26.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cd7837b2b734ca72959a1caf3309457a318c934abef7a43a14bb984e574bbb9a"},
{file = "numpy-1.26.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1c59c046c31a43310ad0199d6299e59f57a289e22f0f36951ced1c9eac3665b9"},
{file = "numpy-1.26.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d58e8c51a7cf43090d124d5073bc29ab2755822181fcad978b12e144e5e5a4b3"},
{file = "numpy-1.26.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6081aed64714a18c72b168a9276095ef9155dd7888b9e74b5987808f0dd0a974"},
{file = "numpy-1.26.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:97e5d6a9f0702c2863aaabf19f0d1b6c2628fbe476438ce0b5ce06e83085064c"},
{file = "numpy-1.26.1-cp311-cp311-win32.whl", hash = "sha256:b9d45d1dbb9de84894cc50efece5b09939752a2d75aab3a8b0cef6f3a35ecd6b"},
{file = "numpy-1.26.1-cp311-cp311-win_amd64.whl", hash = "sha256:3649d566e2fc067597125428db15d60eb42a4e0897fc48d28cb75dc2e0454e53"},
{file = "numpy-1.26.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:1d1bd82d539607951cac963388534da3b7ea0e18b149a53cf883d8f699178c0f"},
{file = "numpy-1.26.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:afd5ced4e5a96dac6725daeb5242a35494243f2239244fad10a90ce58b071d24"},
{file = "numpy-1.26.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a03fb25610ef560a6201ff06df4f8105292ba56e7cdd196ea350d123fc32e24e"},
{file = "numpy-1.26.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dcfaf015b79d1f9f9c9fd0731a907407dc3e45769262d657d754c3a028586124"},
{file = "numpy-1.26.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:e509cbc488c735b43b5ffea175235cec24bbc57b227ef1acc691725beb230d1c"},
{file = "numpy-1.26.1-cp312-cp312-win32.whl", hash = "sha256:af22f3d8e228d84d1c0c44c1fbdeb80f97a15a0abe4f080960393a00db733b66"},
{file = "numpy-1.26.1-cp312-cp312-win_amd64.whl", hash = "sha256:9f42284ebf91bdf32fafac29d29d4c07e5e9d1af862ea73686581773ef9e73a7"},
{file = "numpy-1.26.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:bb894accfd16b867d8643fc2ba6c8617c78ba2828051e9a69511644ce86ce83e"},
{file = "numpy-1.26.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e44ccb93f30c75dfc0c3aa3ce38f33486a75ec9abadabd4e59f114994a9c4617"},
{file = "numpy-1.26.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9696aa2e35cc41e398a6d42d147cf326f8f9d81befcb399bc1ed7ffea339b64e"},
{file = "numpy-1.26.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a5b411040beead47a228bde3b2241100454a6abde9df139ed087bd73fc0a4908"},
{file = "numpy-1.26.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:1e11668d6f756ca5ef534b5be8653d16c5352cbb210a5c2a79ff288e937010d5"},
{file = "numpy-1.26.1-cp39-cp39-win32.whl", hash = "sha256:d1d2c6b7dd618c41e202c59c1413ef9b2c8e8a15f5039e344af64195459e3104"},
{file = "numpy-1.26.1-cp39-cp39-win_amd64.whl", hash = "sha256:59227c981d43425ca5e5c01094d59eb14e8772ce6975d4b2fc1e106a833d5ae2"},
{file = "numpy-1.26.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:06934e1a22c54636a059215d6da99e23286424f316fddd979f5071093b648668"},
{file = "numpy-1.26.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76ff661a867d9272cd2a99eed002470f46dbe0943a5ffd140f49be84f68ffc42"},
{file = "numpy-1.26.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:6965888d65d2848e8768824ca8288db0a81263c1efccec881cb35a0d805fcd2f"},
{file = "numpy-1.26.1.tar.gz", hash = "sha256:c8c6c72d4a9f831f328efb1312642a1cafafaa88981d9ab76368d50d07d93cbe"},
]
[[package]]
@@ -994,35 +994,35 @@ lint = ["lintrunner (>=0.10.0)", "lintrunner-adapters (>=0.3)"]
[[package]]
name = "onnxruntime"
version = "1.16.0"
version = "1.16.1"
description = "ONNX Runtime is a runtime accelerator for Machine Learning models"
optional = true
python-versions = "*"
files = [
{file = "onnxruntime-1.16.0-cp310-cp310-macosx_10_15_x86_64.whl", hash = "sha256:69c86ba3d90c166944c4a3c8a5b2a24a7bc45e68ae5997d83279af21ffd0f5f3"},
{file = "onnxruntime-1.16.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:604a46aa2ad6a51f2fc4df1a984ea571a43aa02424aea93464c32ce02d23b3bb"},
{file = "onnxruntime-1.16.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a40660516b382031279fb690fc3d068ad004173c2bd12bbdc0bd0fe01ef8b7c3"},
{file = "onnxruntime-1.16.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:349fd9c7875c1a76609d45b079484f8059adfb1fb87a30506934fb667ceab249"},
{file = "onnxruntime-1.16.0-cp310-cp310-win32.whl", hash = "sha256:22c9e2f1a1f15b41b01195cd2520c013c22228efc4795ae4118048ea4118aad2"},
{file = "onnxruntime-1.16.0-cp310-cp310-win_amd64.whl", hash = "sha256:b9667a131abfd226a728cc1c1ecf5cc5afa4fff37422f95a84bc22f7c175b57f"},
{file = "onnxruntime-1.16.0-cp311-cp311-macosx_10_15_x86_64.whl", hash = "sha256:f7b292726a1f3fa4a483d7e902da083a5889a86a860dbc3a6479988cad342578"},
{file = "onnxruntime-1.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:61eaf288a2482c5561f620fb686c80c32709e92724bbb59a5e4a0d349429e205"},
{file = "onnxruntime-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5fe2239d5821d5501eecccfe5c408485591b5d73eb76a61491a8f78179c2e65a"},
{file = "onnxruntime-1.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5a4924604fcdf1704b7f7e087b4c0b0e181c58367a687da55b1aec2705631943"},
{file = "onnxruntime-1.16.0-cp311-cp311-win32.whl", hash = "sha256:55d8456f1ab28c32aec9c478b7638ed145102b03bb9b719b79e065ffc5de9c72"},
{file = "onnxruntime-1.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:c2a53ffd456187028c841ac7ed0d83b4c2b7e48bd2b1cf2a42d253ecf1e97cb3"},
{file = "onnxruntime-1.16.0-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:bf5769aa4095cfe2503307867fa95b5f73732909ee21b67fe24da443af445925"},
{file = "onnxruntime-1.16.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c0974deadf11ddab201d915a10517be00fa9d6816def56fa374e4c1a0008985a"},
{file = "onnxruntime-1.16.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99dccf1d2eba5ecd7b6c0e8e80d92d0030291f3506726c156e018a4d7a187c6f"},
{file = "onnxruntime-1.16.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0170ed05d3a8a7c24fe01fc262a6bc603837751f3bb273df7006a2da73f37fff"},
{file = "onnxruntime-1.16.0-cp38-cp38-win32.whl", hash = "sha256:5ecd38e98ccdcbbaa7e529e96852f4c1c136559802354b76378d9a19532018ee"},
{file = "onnxruntime-1.16.0-cp38-cp38-win_amd64.whl", hash = "sha256:1c585c60e9541a9bd4fb319ba9a3ef6122a28dcf4f3dbcdf014df44570cad6f8"},
{file = "onnxruntime-1.16.0-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:efe59c1e51ad647fb18860233f5971e309961d09ca10697170ef9b7d9fa728f4"},
{file = "onnxruntime-1.16.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e3c9a9cccab8f6512a0c0207b2816dd8864f2f720f6e9df5cf01e30c4f80194f"},
{file = "onnxruntime-1.16.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dcf16a252308ec6e0737db7028b63fed0ac28fbad134f86216c0dfb051a31f38"},
{file = "onnxruntime-1.16.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f533aa90ee7189e88b6b612d6adae7d290971090598cfd47ce034ab0d106fc9c"},
{file = "onnxruntime-1.16.0-cp39-cp39-win32.whl", hash = "sha256:306c7f5d8a0c24c65afb34f7deb0bc526defde2249e53538f1dce083945a2d6e"},
{file = "onnxruntime-1.16.0-cp39-cp39-win_amd64.whl", hash = "sha256:df8a00a7b057ba497e2822175cc68731d84b89a6d50a3a2a3ec51e98e9c91125"},
{file = "onnxruntime-1.16.1-cp310-cp310-macosx_10_15_x86_64.whl", hash = "sha256:28b2c7f444b4119950b69370801cd66067f403d19cbaf2a444735d7c269cce4a"},
{file = "onnxruntime-1.16.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c24e04f33e7899f6aebb03ed51e51d346c1f906b05c5569d58ac9a12d38a2f58"},
{file = "onnxruntime-1.16.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9fa93b166f2d97063dc9f33c5118c5729a4a5dd5617296b6dbef42f9047b3e81"},
{file = "onnxruntime-1.16.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:042dd9201b3016ee18f8f8bc4609baf11ff34ca1ff489c0a46bcd30919bf883d"},
{file = "onnxruntime-1.16.1-cp310-cp310-win32.whl", hash = "sha256:c20aa0591f305012f1b21aad607ed96917c86ae7aede4a4dd95824b3d124ceb7"},
{file = "onnxruntime-1.16.1-cp310-cp310-win_amd64.whl", hash = "sha256:5581873e578917bea76d6434ee7337e28195d03488dcf72d161d08e9398c6249"},
{file = "onnxruntime-1.16.1-cp311-cp311-macosx_10_15_x86_64.whl", hash = "sha256:ef8c0c8abf5f309aa1caf35941380839dc5f7a2fa53da533be4a3f254993f120"},
{file = "onnxruntime-1.16.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e680380bea35a137cbc3efd67a17486e96972901192ad3026ee79c8d8fe264f7"},
{file = "onnxruntime-1.16.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e62cc38ce1a669013d0a596d984762dc9c67c56f60ecfeee0d5ad36da5863f6"},
{file = "onnxruntime-1.16.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:025c7a4d57bd2e63b8a0f84ad3df53e419e3df1cc72d63184f2aae807b17c13c"},
{file = "onnxruntime-1.16.1-cp311-cp311-win32.whl", hash = "sha256:9ad074057fa8d028df248b5668514088cb0937b6ac5954073b7fb9b2891ffc8c"},
{file = "onnxruntime-1.16.1-cp311-cp311-win_amd64.whl", hash = "sha256:d5e43a3478bffc01f817ecf826de7b25a2ca1bca8547d70888594ab80a77ad24"},
{file = "onnxruntime-1.16.1-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:3aef4d70b0930e29a8943eab248cd1565664458d3a62b2276bd11181f28fd0a3"},
{file = "onnxruntime-1.16.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:55a7b843a57c8ca0c8ff169428137958146081d5d76f1a6dd444c4ffcd37c3c2"},
{file = "onnxruntime-1.16.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:62c631af1941bf3b5f7d063d24c04aacce8cff0794e157c497e315e89ac5ad7b"},
{file = "onnxruntime-1.16.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5671f296c3d5c233f601e97a10ab5a1dd8e65ba35c7b7b0c253332aba9dff330"},
{file = "onnxruntime-1.16.1-cp38-cp38-win32.whl", hash = "sha256:eb3802305023dd05e16848d4e22b41f8147247894309c0c27122aaa08793b3d2"},
{file = "onnxruntime-1.16.1-cp38-cp38-win_amd64.whl", hash = "sha256:fecfb07443d09d271b1487f401fbdf1ba0c829af6fd4fe8f6af25f71190e7eb9"},
{file = "onnxruntime-1.16.1-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:de3e12094234db6545c67adbf801874b4eb91e9f299bda34c62967ef0050960f"},
{file = "onnxruntime-1.16.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ff723c2a5621b5e7103f3be84d5aae1e03a20621e72219dddceae81f65f240af"},
{file = "onnxruntime-1.16.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:14a7fb3073aaf6b462e3d7fb433320f7700558a8892e5021780522dc4574292a"},
{file = "onnxruntime-1.16.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:963159f1f699b0454cd72fcef3276c8a1aab9389a7b301bcd8e320fb9d9e8597"},
{file = "onnxruntime-1.16.1-cp39-cp39-win32.whl", hash = "sha256:85771adb75190db9364b25ddec353ebf07635b83eb94b64ed014f1f6d57a3857"},
{file = "onnxruntime-1.16.1-cp39-cp39-win_amd64.whl", hash = "sha256:d32d2b30799c1f950123c60ae8390818381fd5f88bdf3627eeca10071c155dc5"},
]
[package.dependencies]
@@ -1301,13 +1301,13 @@ files = [
[[package]]
name = "pyright"
version = "1.1.329"
version = "1.1.331"
description = "Command line wrapper for pyright"
optional = false
python-versions = ">=3.7"
files = [
{file = "pyright-1.1.329-py3-none-any.whl", hash = "sha256:c16f88a7ac14ddd0513e62fec56d69c37e3c6b412161ad16aa23a9c7e3dabaf4"},
{file = "pyright-1.1.329.tar.gz", hash = "sha256:5baf82ff5ecb8c8b3ac400e8536348efbde0b94a09d83d5b440c0d143fd151a8"},
{file = "pyright-1.1.331-py3-none-any.whl", hash = "sha256:d200a01794e7f2a04d5042a6c3abee36ce92780287d3037edfc3604d45488f0e"},
{file = "pyright-1.1.331.tar.gz", hash = "sha256:c3e7b86154cac86c3bd61ea0f963143d001c201e246825aaabdddfcce5d04293"},
]
[package.dependencies]
@@ -1359,13 +1359,13 @@ testing = ["coverage (>=6.2)", "flaky (>=3.5.0)", "hypothesis (>=5.7.1)", "mypy
[[package]]
name = "pytest-timeout"
version = "2.1.0"
version = "2.2.0"
description = "pytest plugin to abort hanging tests"
optional = false
python-versions = ">=3.6"
python-versions = ">=3.7"
files = [
{file = "pytest-timeout-2.1.0.tar.gz", hash = "sha256:c07ca07404c612f8abbe22294b23c368e2e5104b521c1790195561f37e1ac3d9"},
{file = "pytest_timeout-2.1.0-py3-none-any.whl", hash = "sha256:f6f50101443ce70ad325ceb4473c4255e9d74e3c7cd0ef827309dfa4c0d975c6"},
{file = "pytest-timeout-2.2.0.tar.gz", hash = "sha256:3b0b95dabf3cb50bac9ef5ca912fa0cfc286526af17afc806824df20c2f72c90"},
{file = "pytest_timeout-2.2.0-py3-none-any.whl", hash = "sha256:bde531e096466f49398a59f2dde76fa78429a09a12411466f88a07213e220de2"},
]
[package.dependencies]
@@ -1764,4 +1764,4 @@ fastembed = ["fastembed"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.8,<3.13"
content-hash = "f491a0d3e5d7cd8cc90987274aa39ce8e91c6a0febcd5627ea874c470a20c79e"
content-hash = "0df37e1fa4e332c61077b4b1a538285fb21b5d3d18d01859a886a78751669fed"

View File

@@ -27,7 +27,7 @@ grpcio-tools = ">=1.41.0"
urllib3 = "^1.26.14"
portalocker = "^2.7.0"
fastembed = [
{ version = "0.0.5", optional = true, python = "<3.12" }
{ version = "0.1.1", optional = true, python = "<3.12" }
]
[tool.poetry.group.dev.dependencies]

View File

@@ -1,3 +1,14 @@
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
#
# This file is autogenerated. Do not edit it manually.
# To regenerate this file, use
#
# ```
# bash -x tools/generate_async_client.sh
# ```
#
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
from qdrant_client.conversions import common_types as types

View File

@@ -1,3 +1,14 @@
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
#
# This file is autogenerated. Do not edit it manually.
# To regenerate this file, use
#
# ```
# bash -x tools/generate_async_client.sh
# ```
#
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
from qdrant_client import grpc as grpc

View File

@@ -1,3 +1,14 @@
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
#
# This file is autogenerated. Do not edit it manually.
# To regenerate this file, use
#
# ```
# bash -x tools/generate_async_client.sh
# ```
#
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
import uuid
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
@@ -5,6 +16,7 @@ from pydantic import BaseModel
from qdrant_client.async_client_base import AsyncQdrantBase
from qdrant_client.conversions import common_types as types
from qdrant_client.fastembed_common import QueryResponse
from qdrant_client.http import models
from qdrant_client.uploader.uploader import iter_batch
@@ -16,17 +28,12 @@ SUPPORTED_EMBEDDING_MODELS: Dict[str, Tuple[int, models.Distance]] = {
"BAAI/bge-base-en": (768, models.Distance.COSINE),
"sentence-transformers/all-MiniLM-L6-v2": (384, models.Distance.COSINE),
"BAAI/bge-small-en": (384, models.Distance.COSINE),
"BAAI/bge-small-en-v1.5": (384, models.Distance.COSINE),
"BAAI/bge-base-en-v1.5": (768, models.Distance.COSINE),
"intfloat/multilingual-e5-large": (1024, models.Distance.COSINE),
}
class QueryResponse(BaseModel, extra="forbid"):
id: Union[str, int]
embedding: Optional[List[float]]
metadata: Dict[str, Any]
document: str
score: float
class AsyncQdrantFastembedMixin(AsyncQdrantBase):
DEFAULT_EMBEDDING_MODEL = "BAAI/bge-small-en"
embedding_models: Dict[str, "DefaultEmbedding"] = {}
@@ -82,27 +89,37 @@ class AsyncQdrantFastembedMixin(AsyncQdrantBase):
def _embed_documents(
self,
documents: List[str],
documents: Iterable[str],
embedding_model_name: str = DEFAULT_EMBEDDING_MODEL,
batch_size: int = 32,
embed_type: str = "default",
) -> Iterable[List[float]]:
parallel: Optional[int] = None,
) -> Iterable[Tuple[str, List[float]]]:
embedding_model = self._get_or_init_model(model_name=embedding_model_name)
for batch_docs in iter_batch(documents, batch_size):
if embed_type == "passage":
vectors_batches = embedding_model.passage_embed(batch_docs, batch_size=batch_size)
vectors_batches = embedding_model.passage_embed(
batch_docs, batch_size=batch_size, parallel=parallel
)
elif embed_type == "query":
vectors_batches = (
list(embedding_model.query_embed(query=query))[0] for query in batch_docs
)
elif embed_type == "default":
vectors_batches = embedding_model.embed(batch_docs, batch_size=batch_size)
vectors_batches = embedding_model.embed(
batch_docs, batch_size=batch_size, parallel=parallel
)
else:
raise ValueError(f"Unknown embed type: {embed_type}")
for vector in vectors_batches:
yield vector.tolist()
for vector, doc in zip(vectors_batches, batch_docs):
yield (doc, vector.tolist())
def _get_vector_field_name(self) -> str:
def get_vector_field_name(self) -> str:
"""
Returns name of the vector field in qdrant collection, used by current fastembed model.
Returns:
Name of the vector field.
"""
model_name = self.embedding_model_name.split("/")[-1].lower()
return f"fast-{model_name}"
@@ -113,7 +130,7 @@ class AsyncQdrantFastembedMixin(AsyncQdrantBase):
for scored_point in scored_points:
embedding = None
if scored_point.vector is not None:
embedding = scored_point.vector.get(self._get_vector_field_name(), None)
embedding = scored_point.vector.get(self.get_vector_field_name(), None)
response.append(
QueryResponse(
id=scored_point.id,
@@ -125,15 +142,62 @@ class AsyncQdrantFastembedMixin(AsyncQdrantBase):
)
return response
def _records_iterator(
self,
ids: Optional[Iterable[models.ExtendedPointId]],
metadata: Optional[Iterable[Dict[str, Any]]],
encoded_docs: Iterable[Tuple[str, List[float]]],
ids_accumulator: list,
) -> Iterable[models.Record]:
if ids is None:
ids = iter(lambda: uuid.uuid4().hex, None)
if metadata is None:
metadata = iter(lambda: {}, None)
vector_name = self.get_vector_field_name()
for idx, meta, (doc, vector) in zip(ids, metadata, encoded_docs):
ids_accumulator.append(idx)
payload = {"document": doc, **meta}
yield models.Record(id=idx, payload=payload, vector={vector_name: vector})
def get_fastembed_vector_params(
self,
on_disk: Optional[bool] = None,
quantization_config: Optional[models.QuantizationConfig] = None,
hnsw_config: Optional[models.HnswConfigDiff] = None,
) -> Dict[str, models.VectorParams]:
"""
Generates vector configuration, compatible with fastembed models.
Args:
on_disk: if True, vectors will be stored on disk. If None, default value will be used.
quantization_config: Quantization configuration. If None, quantization will be disabled.
hnsw_config: HNSW configuration. If None, default configuration will be used.
Returns:
Configuration for `vectors_config` argument in `create_collection` method.
"""
vector_field_name = self.get_vector_field_name()
embeddings_size, distance = self._get_model_params(model_name=self.embedding_model_name)
return {
vector_field_name: models.VectorParams(
size=embeddings_size,
distance=distance,
on_disk=on_disk,
quantization_config=quantization_config,
hnsw_config=hnsw_config,
)
}
async def add(
self,
collection_name: str,
documents: List[str],
metadata: Optional[List[Dict[str, Any]]] = None,
ids: Optional[List[models.ExtendedPointId]] = None,
documents: Iterable[str],
metadata: Optional[Iterable[Dict[str, Any]]] = None,
ids: Optional[Iterable[models.ExtendedPointId]] = None,
batch_size: int = 32,
parallel: Optional[int] = None,
**kwargs: Any,
) -> List[str]:
) -> List[Union[str, int]]:
"""
Adds text documents into qdrant collection.
If collection does not exist, it will be created with default parameters.
@@ -145,48 +209,40 @@ class AsyncQdrantFastembedMixin(AsyncQdrantBase):
Args:
collection_name (str):
Name of the collection to add documents to.
documents (List[str]):
documents (Iterable[str]):
List of documents to embed and add to the collection.
metadata (List[Dict[str, Any]], optional):
metadata (Iterable[Dict[str, Any]], optional):
List of metadata dicts. Defaults to None.
ids (List[models.ExtendedPointId], optional):
ids (Iterable[models.ExtendedPointId], optional):
List of ids to assign to documents.
If not specified, UUIDs will be generated. Defaults to None.
batch_size (int, optional):
How many documents to embed and upload in single request. Defaults to 32.
parallel (Optional[int], optional):
How many parallel workers to use for embedding. Defaults to None.
If number is specified, data-parallel process will be used.
Raises:
ImportError: If fastembed is not installed.
Returns:
List[str]: List of UUIDs of added documents. UUIDs are randomly generated on client side.
List of IDs of added documents. If no ids provided, UUIDs will be randomly generated on client side.
"""
embeddings = self._embed_documents(
encoded_docs = self._embed_documents(
documents=documents,
embedding_model_name=self.embedding_model_name,
batch_size=batch_size,
embed_type="passage",
parallel=parallel,
)
if metadata is None:
metadata = [{} for _ in range(len(documents))]
else:
assert len(metadata) == len(
documents
), f"metadata length mismatch: {len(metadata)} != {len(documents)}"
payloads = ({"document": doc, **metadata} for (doc, metadata) in zip(documents, metadata))
if ids is None:
ids = [uuid.uuid4().hex for _ in range(len(documents))]
(embeddings_size, distance) = self._get_model_params(model_name=self.embedding_model_name)
vector_field_name = self._get_vector_field_name()
embeddings_size, distance = self._get_model_params(model_name=self.embedding_model_name)
vector_field_name = self.get_vector_field_name()
try:
collection_info = await self.get_collection(collection_name=collection_name)
except Exception:
await self.create_collection(
collection_name=collection_name,
vectors_config={
vector_field_name: models.VectorParams(size=embeddings_size, distance=distance)
},
collection_name=collection_name, vectors_config=self.get_fastembed_vector_params()
)
collection_info = await self.get_collection(collection_name=collection_name)
assert isinstance(
@@ -202,12 +258,19 @@ class AsyncQdrantFastembedMixin(AsyncQdrantBase):
assert (
distance == vector_params.distance
), f"Distance mismatch: {distance} != {vector_params.distance}"
records = (
models.Record(id=idx, payload=payload, vector={vector_field_name: vector})
for (idx, payload, vector) in zip(ids, payloads, embeddings)
inserted_ids: list = []
records = self._records_iterator(
ids=ids, metadata=metadata, encoded_docs=encoded_docs, ids_accumulator=inserted_ids
)
self.upload_records(collection_name=collection_name, records=records, wait=True, **kwargs)
return ids
self.upload_records(
collection_name=collection_name,
records=records,
wait=True,
parallel=parallel or 1,
batch_size=batch_size,
**kwargs,
)
return inserted_ids
async def query(
self,
@@ -244,7 +307,7 @@ class AsyncQdrantFastembedMixin(AsyncQdrantBase):
await self.search(
collection_name=collection_name,
query_vector=models.NamedVector(
name=self._get_vector_field_name(), vector=query_vector.tolist()
name=self.get_vector_field_name(), vector=query_vector.tolist()
),
query_filter=query_filter,
limit=limit,
@@ -290,7 +353,7 @@ class AsyncQdrantFastembedMixin(AsyncQdrantBase):
for vector in query_vectors:
request = models.SearchRequest(
vector=models.NamedVector(
name=self._get_vector_field_name(), vector=vector.tolist()
name=self.get_vector_field_name(), vector=vector.tolist()
),
filter=query_filter,
limit=limit,

View File

@@ -1,3 +1,14 @@
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
#
# This file is autogenerated. Do not edit it manually.
# To regenerate this file, use
#
# ```
# bash -x tools/generate_async_client.sh
# ```
#
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
import logging
import warnings
from multiprocessing import get_all_start_methods
@@ -69,7 +80,7 @@ class AsyncQdrantRemote(AsyncQdrantBase):
if url.startswith("localhost"):
url = f"//{url}"
parsed_url: Url = parse_url(url)
(self._host, self._port) = (parsed_url.host, parsed_url.port)
self._host, self._port = (parsed_url.host, parsed_url.port)
if parsed_url.scheme:
self._https = parsed_url.scheme == "https"
self._scheme = parsed_url.scheme
@@ -138,7 +149,7 @@ class AsyncQdrantRemote(AsyncQdrantBase):
@staticmethod
def _parse_url(url: str) -> Tuple[Optional[str], str, Optional[int], Optional[str]]:
parse_result: Url = parse_url(url)
(scheme, host, port, prefix) = (
scheme, host, port, prefix = (
parse_result.scheme,
parse_result.host,
parse_result.port,
@@ -937,7 +948,7 @@ class AsyncQdrantRemote(AsyncQdrantBase):
assert grpc_result is not None, "Delete vectors returned None result"
return GrpcToRest.convert_update_result(grpc_result)
else:
(_points, _filter) = self._try_argument_to_rest_points_and_filter(points)
_points, _filter = self._try_argument_to_rest_points_and_filter(points)
return (
await self.openapi_client.points_api.delete_vectors(
collection_name=collection_name,
@@ -1157,7 +1168,7 @@ class AsyncQdrantRemote(AsyncQdrantBase):
).result
)
else:
(_points, _filter) = self._try_argument_to_rest_points_and_filter(points)
_points, _filter = self._try_argument_to_rest_points_and_filter(points)
result: Optional[types.UpdateResult] = (
await self.openapi_client.points_api.set_payload(
collection_name=collection_name,
@@ -1197,7 +1208,7 @@ class AsyncQdrantRemote(AsyncQdrantBase):
).result
)
else:
(_points, _filter) = self._try_argument_to_rest_points_and_filter(points)
_points, _filter = self._try_argument_to_rest_points_and_filter(points)
result: Optional[types.UpdateResult] = (
await self.openapi_client.points_api.overwrite_payload(
collection_name=collection_name,
@@ -1237,7 +1248,7 @@ class AsyncQdrantRemote(AsyncQdrantBase):
).result
)
else:
(_points, _filter) = self._try_argument_to_rest_points_and_filter(points)
_points, _filter = self._try_argument_to_rest_points_and_filter(points)
result: Optional[types.UpdateResult] = (
await self.openapi_client.points_api.delete_payload(
collection_name=collection_name,

View File

@@ -0,0 +1,11 @@
from typing import Any, Dict, List, Optional, Union
from pydantic import BaseModel
class QueryResponse(BaseModel, extra="forbid"): # type: ignore
id: Union[str, int]
embedding: Optional[List[float]]
metadata: Dict[str, Any]
document: str
score: float

View File

@@ -5,6 +5,7 @@ from pydantic import BaseModel
from qdrant_client.client_base import QdrantBase
from qdrant_client.conversions import common_types as types
from qdrant_client.fastembed_common import QueryResponse
from qdrant_client.http import models
from qdrant_client.uploader.uploader import iter_batch
@@ -17,17 +18,12 @@ SUPPORTED_EMBEDDING_MODELS: Dict[str, Tuple[int, models.Distance]] = {
"BAAI/bge-base-en": (768, models.Distance.COSINE),
"sentence-transformers/all-MiniLM-L6-v2": (384, models.Distance.COSINE),
"BAAI/bge-small-en": (384, models.Distance.COSINE),
"BAAI/bge-small-en-v1.5": (384, models.Distance.COSINE),
"BAAI/bge-base-en-v1.5": (768, models.Distance.COSINE),
"intfloat/multilingual-e5-large": (1024, models.Distance.COSINE),
}
class QueryResponse(BaseModel, extra="forbid"): # type: ignore
id: Union[str, int]
embedding: Optional[List[float]]
metadata: Dict[str, Any]
document: str
score: float
class QdrantFastembedMixin(QdrantBase):
DEFAULT_EMBEDDING_MODEL = "BAAI/bge-small-en"
@@ -92,27 +88,37 @@ class QdrantFastembedMixin(QdrantBase):
def _embed_documents(
self,
documents: List[str],
documents: Iterable[str],
embedding_model_name: str = DEFAULT_EMBEDDING_MODEL,
batch_size: int = 32,
embed_type: str = "default",
) -> Iterable[List[float]]:
parallel: Optional[int] = None,
) -> Iterable[Tuple[str, List[float]]]:
embedding_model = self._get_or_init_model(model_name=embedding_model_name)
for batch_docs in iter_batch(documents, batch_size):
if embed_type == "passage":
vectors_batches = embedding_model.passage_embed(batch_docs, batch_size=batch_size)
vectors_batches = embedding_model.passage_embed(
batch_docs, batch_size=batch_size, parallel=parallel
)
elif embed_type == "query":
vectors_batches = (
list(embedding_model.query_embed(query=query))[0] for query in batch_docs
)
elif embed_type == "default":
vectors_batches = embedding_model.embed(batch_docs, batch_size=batch_size)
vectors_batches = embedding_model.embed(
batch_docs, batch_size=batch_size, parallel=parallel
)
else:
raise ValueError(f"Unknown embed type: {embed_type}")
for vector in vectors_batches:
yield vector.tolist()
for vector, doc in zip(vectors_batches, batch_docs):
yield doc, vector.tolist()
def _get_vector_field_name(self) -> str:
def get_vector_field_name(self) -> str:
"""
Returns name of the vector field in qdrant collection, used by current fastembed model.
Returns:
Name of the vector field.
"""
model_name = self.embedding_model_name.split("/")[-1].lower()
return f"fast-{model_name}"
@@ -124,7 +130,7 @@ class QdrantFastembedMixin(QdrantBase):
for scored_point in scored_points:
embedding = None
if scored_point.vector is not None:
embedding = scored_point.vector.get(self._get_vector_field_name(), None)
embedding = scored_point.vector.get(self.get_vector_field_name(), None)
response.append(
QueryResponse(
@@ -137,15 +143,65 @@ class QdrantFastembedMixin(QdrantBase):
)
return response
def _records_iterator(
self,
ids: Optional[Iterable[models.ExtendedPointId]],
metadata: Optional[Iterable[Dict[str, Any]]],
encoded_docs: Iterable[Tuple[str, List[float]]],
ids_accumulator: list,
) -> Iterable[models.Record]:
if ids is None:
ids = iter(lambda: uuid.uuid4().hex, None)
if metadata is None:
metadata = iter(lambda: {}, None)
vector_name = self.get_vector_field_name()
for idx, meta, (doc, vector) in zip(ids, metadata, encoded_docs):
ids_accumulator.append(idx)
payload = {"document": doc, **meta}
yield models.Record(id=idx, payload=payload, vector={vector_name: vector})
def get_fastembed_vector_params(
self,
on_disk: Optional[bool] = None,
quantization_config: Optional[models.QuantizationConfig] = None,
hnsw_config: Optional[models.HnswConfigDiff] = None,
) -> Dict[str, models.VectorParams]:
"""
Generates vector configuration, compatible with fastembed models.
Args:
on_disk: if True, vectors will be stored on disk. If None, default value will be used.
quantization_config: Quantization configuration. If None, quantization will be disabled.
hnsw_config: HNSW configuration. If None, default configuration will be used.
Returns:
Configuration for `vectors_config` argument in `create_collection` method.
"""
vector_field_name = self.get_vector_field_name()
embeddings_size, distance = self._get_model_params(model_name=self.embedding_model_name)
return {
vector_field_name: models.VectorParams(
size=embeddings_size,
distance=distance,
on_disk=on_disk,
quantization_config=quantization_config,
hnsw_config=hnsw_config,
)
}
def add(
self,
collection_name: str,
documents: List[str],
metadata: Optional[List[Dict[str, Any]]] = None,
ids: Optional[List[models.ExtendedPointId]] = None,
documents: Iterable[str],
metadata: Optional[Iterable[Dict[str, Any]]] = None,
ids: Optional[Iterable[models.ExtendedPointId]] = None,
batch_size: int = 32,
parallel: Optional[int] = None,
**kwargs: Any,
) -> List[str]:
) -> List[Union[str, int]]:
"""
Adds text documents into qdrant collection.
If collection does not exist, it will be created with default parameters.
@@ -157,47 +213,38 @@ class QdrantFastembedMixin(QdrantBase):
Args:
collection_name (str):
Name of the collection to add documents to.
documents (List[str]):
documents (Iterable[str]):
List of documents to embed and add to the collection.
metadata (List[Dict[str, Any]], optional):
metadata (Iterable[Dict[str, Any]], optional):
List of metadata dicts. Defaults to None.
ids (List[models.ExtendedPointId], optional):
ids (Iterable[models.ExtendedPointId], optional):
List of ids to assign to documents.
If not specified, UUIDs will be generated. Defaults to None.
batch_size (int, optional):
How many documents to embed and upload in single request. Defaults to 32.
parallel (Optional[int], optional):
How many parallel workers to use for embedding. Defaults to None.
If number is specified, data-parallel process will be used.
Raises:
ImportError: If fastembed is not installed.
Returns:
List[str]: List of UUIDs of added documents. UUIDs are randomly generated on client side.
List of IDs of added documents. If no ids provided, UUIDs will be randomly generated on client side.
"""
# check if we have fastembed installed
embeddings = self._embed_documents(
encoded_docs = self._embed_documents(
documents=documents,
embedding_model_name=self.embedding_model_name,
batch_size=batch_size,
embed_type="passage",
parallel=parallel,
)
if metadata is None:
metadata = [{} for _ in range(len(documents))]
else:
assert len(metadata) == len(
documents
), f"metadata length mismatch: {len(metadata)} != {len(documents)}"
payloads = ({"document": doc, **metadata} for doc, metadata in zip(documents, metadata))
if ids is None:
ids = [uuid.uuid4().hex for _ in range(len(documents))]
embeddings_size, distance = self._get_model_params(model_name=self.embedding_model_name)
vector_field_name = self._get_vector_field_name()
vector_field_name = self.get_vector_field_name()
# Check if collection by same name exists, if not, create it
try:
@@ -205,9 +252,7 @@ class QdrantFastembedMixin(QdrantBase):
except Exception:
self.create_collection(
collection_name=collection_name,
vectors_config={
vector_field_name: models.VectorParams(size=embeddings_size, distance=distance)
},
vectors_config=self.get_fastembed_vector_params(),
)
collection_info = self.get_collection(collection_name=collection_name)
@@ -230,19 +275,25 @@ class QdrantFastembedMixin(QdrantBase):
distance == vector_params.distance
), f"Distance mismatch: {distance} != {vector_params.distance}"
records = (
models.Record(id=idx, payload=payload, vector={vector_field_name: vector})
for idx, payload, vector in zip(ids, payloads, embeddings)
inserted_ids: list = []
records = self._records_iterator(
ids=ids,
metadata=metadata,
encoded_docs=encoded_docs,
ids_accumulator=inserted_ids,
)
self.upload_records(
collection_name=collection_name,
records=records,
wait=True,
parallel=parallel or 1,
batch_size=batch_size,
**kwargs,
)
return ids
return inserted_ids
def query(
self,
@@ -280,7 +331,7 @@ class QdrantFastembedMixin(QdrantBase):
self.search(
collection_name=collection_name,
query_vector=models.NamedVector(
name=self._get_vector_field_name(), vector=query_vector.tolist()
name=self.get_vector_field_name(), vector=query_vector.tolist()
),
query_filter=query_filter,
limit=limit,
@@ -326,7 +377,7 @@ class QdrantFastembedMixin(QdrantBase):
for vector in query_vectors:
request = models.SearchRequest(
vector=models.NamedVector(
name=self._get_vector_field_name(), vector=vector.tolist()
name=self.get_vector_field_name(), vector=vector.tolist()
),
filter=query_filter,
limit=limit,

View File

@@ -1,6 +1,8 @@
import ast
from typing import List
from tools.async_client_generator.config import AUTOGEN_WARNING_MESSAGE
class BaseGenerator:
def __init__(self) -> None:
@@ -12,4 +14,4 @@ class BaseGenerator:
for transformer in self.transformers:
nodes = transformer.visit(nodes)
return ast.unparse(nodes)
return AUTOGEN_WARNING_MESSAGE + ast.unparse(nodes)

View File

@@ -3,3 +3,18 @@ from pathlib import Path
CODE_DIR = Path(__file__).parent
ROOT_DIR = CODE_DIR.parent.parent
CLIENT_DIR = ROOT_DIR / "qdrant_client"
AUTOGEN_WARNING_MESSAGE = """
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
#
# This file is autogenerated. Do not edit it manually.
# To regenerate this file, use
#
# ```
# bash -x tools/generate_async_client.sh
# ```
#
# ****** WARNING: THIS FILE IS AUTOGENERATED ******
"""

View File

@@ -54,6 +54,8 @@ if __name__ == "__main__":
keep_sync=[
"__init__",
"set_model",
"get_vector_field_name",
"get_fastembed_vector_params",
],
class_replace_map={
"QdrantBase": "AsyncQdrantBase",