2026-1-6
This commit is contained in:
@@ -0,0 +1 @@
|
||||
pip
|
||||
217
venv/Lib/site-packages/dashvector-1.0.22.dist-info/LICENSE.txt
Normal file
217
venv/Lib/site-packages/dashvector-1.0.22.dist-info/LICENSE.txt
Normal file
@@ -0,0 +1,217 @@
|
||||
Copyright 2023 Alibaba Inc. All rights reserved.
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
############################################################################
|
||||
|
||||
Open-Source Code Included in DashVector Python Library
|
||||
|
||||
3-clause BSD License (https://raw.githubusercontent.com/numpy/numpy/master/LICENSE.txt)
|
||||
|
||||
* Software: numpy - Version between 1.18.5 and 1.21.6 (https://pypi.org/project/numpy/)
|
||||
* Software: protobuf - Version between 3.8.0 and 3.20.3 (https://pypi.org/project/protobuf/)
|
||||
|
||||
Apache License 2.0 (https://raw.githubusercontent.com/grpc/grpc/master/LICENSE)
|
||||
|
||||
* Software: grpcio - Version between 1.22.0 and 1.55.0 (https://pypi.org/project/grpcio/)
|
||||
* Software: aiohttp - Version between 3.1.0 and 3.8.4 (https://pypi.org/project/aiohttp/)
|
||||
540
venv/Lib/site-packages/dashvector-1.0.22.dist-info/METADATA
Normal file
540
venv/Lib/site-packages/dashvector-1.0.22.dist-info/METADATA
Normal file
@@ -0,0 +1,540 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: dashvector
|
||||
Version: 1.0.22
|
||||
Summary: DashVector Client Python Sdk Library
|
||||
Home-page: https://github.com/alibaba/proxima
|
||||
License: Apache-2.0
|
||||
Keywords: DashVector,vector,database,cloud
|
||||
Author: Alibaba
|
||||
Requires-Python: >=3.9,<4.0
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: Apache Software License
|
||||
Classifier: Programming Language :: Python
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.9
|
||||
Classifier: Programming Language :: Python :: 3.10
|
||||
Classifier: Programming Language :: Python :: 3.11
|
||||
Classifier: Programming Language :: Python :: 3.12
|
||||
Classifier: Topic :: Database
|
||||
Classifier: Topic :: Software Development
|
||||
Classifier: Topic :: Software Development :: Libraries
|
||||
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
||||
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
||||
Requires-Dist: aiohttp (>=3.1.0,<4.0.0)
|
||||
Requires-Dist: certifi (>=2023.7.22,<2024.0.0)
|
||||
Requires-Dist: grpcio (>=1.44.0) ; python_version >= "3.8" and python_version < "3.11"
|
||||
Requires-Dist: grpcio (>=1.59.0) ; python_version >= "3.11" and python_version < "4.0"
|
||||
Requires-Dist: importlib_metadata
|
||||
Requires-Dist: numpy
|
||||
Requires-Dist: protobuf (>=5.29,<6.0)
|
||||
Project-URL: Documentation, https://help.aliyun.com/document_detail/2510225.html
|
||||
Description-Content-Type: text/markdown
|
||||
|
||||
# DashVector Client Python Library
|
||||
|
||||
DashVector is a scalable and fully-managed vector-database service for building various machine learning applications. The DashVector client SDK is your gateway to access the DashVector service.
|
||||
|
||||
For more information about DashVector, please visit: https://help.aliyun.com/document_detail/2510225.html
|
||||
|
||||
## Installation
|
||||
To install the DashVector client Python SDK, simply run:
|
||||
```shell
|
||||
pip install dashvector
|
||||
```
|
||||
|
||||
## QuickStart
|
||||
|
||||
```python
|
||||
import numpy as np
|
||||
import dashvector
|
||||
|
||||
# Use DashVector `Client` api to communicate with the backend vectorDB service.
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
|
||||
# Create a collection named "quickstart" with dimension of 4, using the default Cosine distance metric
|
||||
rsp = client.create(name='quickstart', dimension=4)
|
||||
assert rsp
|
||||
|
||||
# Get a collection by name
|
||||
collection = client.get(name='quickstart')
|
||||
|
||||
# Operations on 'Collection' includes Inert/Query/Upsert/Update/Delete/Fetch of docs
|
||||
# Here we insert sample data (4-dimensional vectors) in batches of 16
|
||||
collection.insert(
|
||||
[
|
||||
dashvector.Doc(id=str(i), vector=np.random.rand(4), fields={'anykey': 'anyvalue'})
|
||||
for i in range(16)
|
||||
]
|
||||
)
|
||||
|
||||
# Query a vector from the collection
|
||||
docs = collection.query([0.1, 0.2, 0.3, 0.4], topk=5)
|
||||
print(docs)
|
||||
|
||||
# Get statistics about collection
|
||||
stats = collection.stats()
|
||||
print(stats)
|
||||
|
||||
# Delete a collection by name
|
||||
client.delete(name='quickstart')
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
### Create a Client
|
||||
`Client` host various APIs for interacting with DashVector `Collection`.
|
||||
|
||||
```python
|
||||
dashvector.Client(
|
||||
api_key: str,
|
||||
endpoint: str = 'dashvector.cn-hangzhou.aliyuncs.com',
|
||||
protocal: dashvector.DashVectorProtocol = dashvector.DashVectorProtocol.GRPC,
|
||||
timeout: float = 10.0
|
||||
) -> Client
|
||||
```
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|--------------------|----------|----------------------------------------------------------------------------------------------|
|
||||
| api_key | str | Yes | Your DashVector API-KEY |
|
||||
| endpoint | str | No | Service Endpoint. <br/>Default value: `dashvector.cn-hangzhou.aliyuncs.com` |
|
||||
| protocol | DashVectorProtocol | No | Communication protocol, support HTTP and GRPC. <br/>Default value: `DashVectorProtocol.GRPC` |
|
||||
| timeout | float | No | Timeout period (in seconds), -1 means no timeout. <br/>Default value: `10.0` |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
assert client
|
||||
```
|
||||
|
||||
### Create Collection
|
||||
```python
|
||||
Client.create(
|
||||
name: str,
|
||||
dimension: int,
|
||||
dtype: Union[Type[int], Type[float]] = float,
|
||||
fields_schema: Optional[Dict[str, Union[Type[str], Type[int], Type[float], Type[bool]]]] = None,
|
||||
metric: str = 'cosine',
|
||||
timeout: Optional[int] = None
|
||||
) -> DashVectorResponse
|
||||
```
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|----------------|----------------------------------------------------------------------------|----------|------------------------------------------------------------------------------------------------------------------|
|
||||
| name | str | Yes | The name of the Collection to create. |
|
||||
| dimension | int | Yes | The dimensions of the Collection's vectors. Valid values: 1-20,000 |
|
||||
| dtype | Union[Type[int], Type[float]] | No | The date type of the Collection's vectors.<br/>Default value: `Type[float]` |
|
||||
| fields_schema | Optional[Dict[str, Union[Type[str], Type[int], Type[float], Type[bool]]]] | No | Fields schema of the Collection.<br/>Default value: `None`<br/>e.g. `{"name": str, "age": int}` |
|
||||
| metric | str | No | Vector similarity metric. For `cosine`, dtype must be `float`.<br/>Valid values:<br/> 1. (Default)`cosine`<br/>2. `dotproduct`<br/>3. `euclidean` |
|
||||
| timeout | Optional[int] | No | Timeout period (in seconds), -1 means asynchronous creation collection.<br/>Default value: `None` |
|
||||
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
|
||||
rsp = client.create('YOUR-COLLECTION-NAME', dimension=4)
|
||||
assert rsp
|
||||
```
|
||||
|
||||
### List Collections
|
||||
`Client.list() -> DashVectorResponse`
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
|
||||
collections = client.list()
|
||||
|
||||
for collection in collections:
|
||||
print(collection)
|
||||
# outputs:
|
||||
# 'quickstart'
|
||||
```
|
||||
|
||||
### Describe Collection
|
||||
`Client.describe(name: str) -> DashVectorResponse`
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-------|----------|-----------------------------------------|
|
||||
| name | str | Yes | The name of the Collection to describe. |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
rsp = client.describe('YOUR-COLLECTION-NAME')
|
||||
|
||||
print(rsp)
|
||||
# example output:
|
||||
# {
|
||||
# "request_id": "8d3ac14e-5382-4736-b77c-4318761ddfab",
|
||||
# "code": 0,
|
||||
# "message": "",
|
||||
# "output": {
|
||||
# "name": "quickstart",
|
||||
# "dimension": 4,
|
||||
# "dtype": "FLOAT",
|
||||
# "metric": "dotproduct",
|
||||
# "fields_schema": {
|
||||
# "name": "STRING",
|
||||
# "age": "INT",
|
||||
# "height": "FLOAT"
|
||||
# },
|
||||
# "status": "SERVING",
|
||||
# "partitions": {
|
||||
# "default": "SERVING"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
```
|
||||
|
||||
### Delete Collection
|
||||
`Client.delete(name: str) -> DashVectorResponse`
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-------|----------|---------------------------------------|
|
||||
| name | str | Yes | The name of the Collection to delete. |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
client.delete('YOUR-COLLECTION-NAME')
|
||||
```
|
||||
|
||||
### Get a Collection Instance
|
||||
`Collection` provides APIs for accessing `Doc` and `Partition`
|
||||
|
||||
`Client.get(name: str) -> Collection`
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-------|----------|------------------------------------|
|
||||
| name | str | Yes | The name of the Collection to get. |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
assert collection
|
||||
```
|
||||
|
||||
### Describe Collection Statistics
|
||||
`Collection.stats() -> DashVectorResponse`
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
rsp = collection.stats()
|
||||
|
||||
print(rsp)
|
||||
# example output:
|
||||
# {
|
||||
# "request_id": "14448bcb-c9a3-49a8-9152-0de3990bce59",
|
||||
# "code": 0,
|
||||
# "message": "Success",
|
||||
# "output": {
|
||||
# "total_doc_count": "26",
|
||||
# "index_completeness": 1.0,
|
||||
# "partitions": {
|
||||
# "default": {
|
||||
# "total_doc_count": "26"
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
```
|
||||
|
||||
### Insert/Update/Upsert Docs
|
||||
```python
|
||||
Collection.insert(
|
||||
docs: Union[Doc, List[Doc], Tuple, List[Tuple]],
|
||||
partition: Optional[str] = None,
|
||||
async_req: False
|
||||
) -> DashVectorResponse
|
||||
```
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-------------------------------------------|----------|------------------------------------------------------------------------|
|
||||
| docs | Union[Doc, List[Doc], Tuple, List[Tuple]] | Yes | The docs to Insert/Update/Upsert. |
|
||||
| partition | Optional[str] | No | Name of the partition to Insert/Update/Upsert.<br/>Default value: `None` |
|
||||
| async_req | bool | No | Enable async request or not.<br/>Default value: `False` |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
import numpy as np
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
|
||||
# insert a doc with Tuple
|
||||
collection.insert(('YOUR-DOC-ID1', [0.1, 0.2, 0.3, 0.4]))
|
||||
collection.insert(('YOUR-DOC-ID2', [0.2, 0.3, 0.4, 0.5], {'age': 30, 'name': 'alice', 'anykey': 'anyvalue'}))
|
||||
|
||||
# insert a doc with dashvector.Doc
|
||||
collection.insert(
|
||||
dashvector.Doc(
|
||||
id='YOUR-DOC-ID3',
|
||||
vector=[0.3, 0.4, 0.5, 0.6],
|
||||
fields={'foo': 'bar'}
|
||||
)
|
||||
)
|
||||
|
||||
# insert in batches
|
||||
ret = collection.insert(
|
||||
[
|
||||
('YOUR-DOC-ID4', [0.2, 0.7, 0.8, 1.3], {'age': 1}),
|
||||
('YOUR-DOC-ID4', [0.3, 0.6, 0.9, 1.2], {'age': 2}),
|
||||
('YOUR-DOC-ID6', [0.4, 0.5, 1.0, 1.1], {'age': 3})
|
||||
]
|
||||
)
|
||||
|
||||
# insert in batches
|
||||
ret = collection.insert(
|
||||
[
|
||||
dashvector.Doc(id=str(i), vector=np.random.rand(4)) for i in range(10)
|
||||
]
|
||||
)
|
||||
|
||||
# async insert
|
||||
ret_funture = collection.insert(
|
||||
[
|
||||
dashvector.Doc(id=str(i+10), vector=np.random.rand(4)) for i in range(10)
|
||||
],
|
||||
async_req=True
|
||||
)
|
||||
ret = ret_funture.get()
|
||||
```
|
||||
|
||||
### Query a Collection
|
||||
```python
|
||||
Collection.query(
|
||||
vector: Optional[Union[List[Union[int, float]], np.ndarray]] = None,
|
||||
id: Optional[str] = None,
|
||||
topk: int = 10,
|
||||
filter: Optional[str] = None,
|
||||
include_vector: bool = False,
|
||||
partition: Optional[str] = None,
|
||||
output_fields: Optional[List[str]] = None,
|
||||
async_req: False
|
||||
) -> DashVectorResponse
|
||||
```
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|-----------------|------------------------------------------------------|----------|--------------------------------------------------------------------------------------------------------------|
|
||||
| vector | Optional[Union[List[Union[int, float]], np.ndarray]] | No | The vector to query |
|
||||
| id | Optional[str] | No | The doc id to query.<br/>Setting `id` means searching by vector corresponding to the id |
|
||||
| topk | Optional[str] | No | Number of similarity results to return.<br/>Default value: `10` |
|
||||
| filter | Optional[str] | No | Expression used to filter results <br/>Default value: None <br/>e.g. `age>20` |
|
||||
| include_vector | bool | No | Return vector details or not.<br/>Default value: `False` |
|
||||
| partition | Optional[str] | No | Name of the partition to Query.<br/>Default value: `None` |
|
||||
| output_fields | Optional[List[str]] | No | List of field names to return.<br/>Default value: `None`, means return all fields<br/>e.g. `['name', 'age']` |
|
||||
| async_req | bool | No | Enable async request or not.<br/>Default value: `False` |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
match_docs = collection.query([0.1, 0.2, 0.3, 0.4], topk=100, filter='age>20', include_vector=True, output_fields=['age','name','foo'])
|
||||
if match_docs:
|
||||
for doc in match_docs:
|
||||
print(doc.id)
|
||||
print(doc.vector)
|
||||
print(doc.fields)
|
||||
print(doc.score)
|
||||
```
|
||||
|
||||
### Delete Docs
|
||||
```python
|
||||
collection.delete(
|
||||
ids: Union[str, List[str]],
|
||||
delete_all: bool = False,
|
||||
partition: Optional[str] = None,
|
||||
async_req: bool = False
|
||||
) -> DashVectorResponse
|
||||
```
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-----------------------|----------|-----------------------------------------------------------------|
|
||||
| ids | Union[str, List[str]] | Yes | The id (or list of ids) for the Doc(s) to Delete |
|
||||
| delete_all | bool | No | Delete all vectors from partition.<br/>Default value: `False` |
|
||||
| partition | Optional[str] | No | Name of the partition to Delete from.<br/>Default value: `None` |
|
||||
| async_req | bool | No | Enable async request or not.<br/>Default value: `False` |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
collection.delete(['YOUR-DOC-ID1','YOUR-DOC-ID2'])
|
||||
```
|
||||
|
||||
### Fetch Docs
|
||||
```python
|
||||
Collection.fetch(
|
||||
ids: Union[str, List[str]],
|
||||
partition: Optional[str] = None,
|
||||
async_req: bool = False
|
||||
) -> DashVectorResponse
|
||||
```
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-----------------------|----------|----------------------------------------------------------------|
|
||||
| ids | Union[str, List[str]] | Yes | The id (or list of ids) for the Doc(s) to Fetch |
|
||||
| partition | Optional[str] | No | Name of the partition to Fetch from.<br/>Default value: `None` |
|
||||
| async_req | bool | No | Enable async request or not.<br/>Default value: `False` |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
fetch_docs = collection.fetch(['YOUR-DOC-ID1', 'YOUR-DOC-ID2'])
|
||||
if fetch_docs:
|
||||
for doc_id in fetch_docs:
|
||||
doc = fetch_docs[doc_id]
|
||||
print(doc.id)
|
||||
print(doc.vector)
|
||||
print(doc.fields)
|
||||
```
|
||||
|
||||
### Create Collection Partition
|
||||
`Collection.create_partition(name: str) -> DashVectorResponse`
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|----------------|----------|-------------------------------------------------------------------------------------------------------|
|
||||
| name | str | Yes | The name of the Partition to Create. |
|
||||
| timeout | Optional[int] | No | Timeout period (in seconds), -1 means asynchronous creation partition.<br/>Default value: `None` |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
rsp = collection.create_partition('YOUR-PARTITION-NAME')
|
||||
assert rsp
|
||||
```
|
||||
|
||||
### Delete Collection Partition
|
||||
`Collection.delete_partition(name: str) -> DashVectorResponse`
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-------|----------|--------------------------------------|
|
||||
| name | str | Yes | The name of the Partition to Delete. |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
rsp = collection.delete_partition('YOUR-PARTITION-NAME')
|
||||
assert rsp
|
||||
```
|
||||
|
||||
### List Collection Partitions
|
||||
`Collection.list_partitions() -> DashVectorResponse`
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
partitions = collection.list_partitions()
|
||||
|
||||
assert partitions
|
||||
for pt in partitions:
|
||||
print(pt)
|
||||
```
|
||||
|
||||
### Describe Collection Partition
|
||||
`Collection.describe_partition(name: str) -> DashVectorResponse`
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-------|----------|----------------------------------------|
|
||||
| name | str | Yes | The name of the Partition to Describe. |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
|
||||
rsp = collection.describe_partition('shoes')
|
||||
print(rsp)
|
||||
# example output:
|
||||
# {"request_id":"296267a7-68e2-483a-87e6-5992d85a5806","code":0,"message":"","output":"SERVING"}
|
||||
```
|
||||
|
||||
### Statistics for Collection Partition
|
||||
`Collection.stats_partition(name: str) -> DashVectorResponse`
|
||||
|
||||
| Parameters | Type | Required | Description |
|
||||
|------------|-------|----------|----------------------------------------------|
|
||||
| name | str | Yes | The name of the Partition to get Statistics. |
|
||||
|
||||
Example:
|
||||
```python
|
||||
import dashvector
|
||||
|
||||
client = dashvector.Client(api_key='YOUR-DASHVECTOR-API-KEY')
|
||||
collection = client.get('YOUR-COLLECTION-NAME')
|
||||
|
||||
rsp = collection.stats_partition('shoes')
|
||||
print(rsp)
|
||||
# example outptut:
|
||||
# {
|
||||
# "code":0,
|
||||
# "message":"",
|
||||
# "requests_id":"330a2bcb-e4a7-4fc6-a711-2fe5f8a24e8c",
|
||||
# "output":{
|
||||
# "total_doc_count":0
|
||||
# }
|
||||
# }
|
||||
```
|
||||
|
||||
|
||||
## Class
|
||||
### dashvector.Doc
|
||||
```python
|
||||
@dataclass(frozen=True)
|
||||
class Doc(object):
|
||||
id: str
|
||||
vector: Union[List[int], List[float], numpy.ndarray]
|
||||
fields: Optional[Dict[str, Union[Type[str], Type[int], Type[float], Type[bool]]]] = None
|
||||
score: float = 0.0
|
||||
```
|
||||
|
||||
### dashvector.DashVectorResponse
|
||||
|
||||
```python
|
||||
class DashVectorResponse(object):
|
||||
code: DashVectorCode
|
||||
message: str
|
||||
request_id: str
|
||||
output: Any
|
||||
```
|
||||
|
||||
## License
|
||||
This project is licensed under the Apache License (Version 2.0).
|
||||
95
venv/Lib/site-packages/dashvector-1.0.22.dist-info/RECORD
Normal file
95
venv/Lib/site-packages/dashvector-1.0.22.dist-info/RECORD
Normal file
@@ -0,0 +1,95 @@
|
||||
dashvector-1.0.22.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
dashvector-1.0.22.dist-info/LICENSE.txt,sha256=GYJChq297x8HRI7yfGLcHdK-evsn6Sv7k68UCeGTu9w,12090
|
||||
dashvector-1.0.22.dist-info/METADATA,sha256=tyf5PadbzNCsh5hBO1aXJOcCV6f1fylKzgMdE62RHDk,19949
|
||||
dashvector-1.0.22.dist-info/RECORD,,
|
||||
dashvector-1.0.22.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
dashvector-1.0.22.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
||||
dashvector/__init__.py,sha256=d51J0TVujpnGSZsMIK7pEWeFob82CeT4VjDPAFr8djw,1433
|
||||
dashvector/__pycache__/__init__.cpython-312.pyc,,
|
||||
dashvector/__pycache__/version.cpython-312.pyc,,
|
||||
dashvector/common/__init__.py,sha256=ZiiWcXjS5x0Ov_ATOcVUgW2pH1dqRUbNdZl2MLXKJGg,671
|
||||
dashvector/common/__pycache__/__init__.cpython-312.pyc,,
|
||||
dashvector/common/__pycache__/common_validator.cpython-312.pyc,,
|
||||
dashvector/common/__pycache__/constants.cpython-312.pyc,,
|
||||
dashvector/common/__pycache__/error.cpython-312.pyc,,
|
||||
dashvector/common/__pycache__/handler.cpython-312.pyc,,
|
||||
dashvector/common/__pycache__/logging.cpython-312.pyc,,
|
||||
dashvector/common/__pycache__/status.cpython-312.pyc,,
|
||||
dashvector/common/__pycache__/types.cpython-312.pyc,,
|
||||
dashvector/common/__pycache__/vector_validator.cpython-312.pyc,,
|
||||
dashvector/common/common_validator.py,sha256=x9RzNI0CUn-tGiMyVctImxF1LW9MUPV2m8KNHMGAptw,20160
|
||||
dashvector/common/constants.py,sha256=v5qeBhOftgrHB8VJSz2frbRPejWYO-B66ijY5XuIpDU,1372
|
||||
dashvector/common/error.py,sha256=dV5Nfct6S1r7B_0VfSXWIC6Rr2UDnbtmEIV4FIqjU1o,3987
|
||||
dashvector/common/handler.py,sha256=lIS1QHEoeLt9dDbScRFm9hfLsDAPO29J5ZIrdetNBD0,6271
|
||||
dashvector/common/logging.py,sha256=9_G-pkPpk0KtwBDSbYPyYajSW7EKcCQLIAEuDuaHlSs,1671
|
||||
dashvector/common/status.py,sha256=hC5-nY0zUow1SNTc5IxvX2jDSdhUOgj_J1VtojRR26Y,2007
|
||||
dashvector/common/types.py,sha256=qMmYtdm2xWIxtZj2Wri9QhPEpm_VmKZSIm4swk9dAr4,28818
|
||||
dashvector/common/vector_validator.py,sha256=G6S1_kTQcIMYXcXhlpolHgS9z4mir1Om2UmeP_SFuLo,11476
|
||||
dashvector/core/__init__.py,sha256=ZiiWcXjS5x0Ov_ATOcVUgW2pH1dqRUbNdZl2MLXKJGg,671
|
||||
dashvector/core/__pycache__/__init__.cpython-312.pyc,,
|
||||
dashvector/core/__pycache__/client.cpython-312.pyc,,
|
||||
dashvector/core/__pycache__/collection.cpython-312.pyc,,
|
||||
dashvector/core/__pycache__/doc.cpython-312.pyc,,
|
||||
dashvector/core/__pycache__/group.cpython-312.pyc,,
|
||||
dashvector/core/client.py,sha256=i-g7A_slYq1m-dds6YkMrWTh3eglqHas3CWwTDYtQv0,15331
|
||||
dashvector/core/collection.py,sha256=2h_iFzwuyMpGILc8rjahkYBSID1yPgen2jGdIk1CsFM,32712
|
||||
dashvector/core/doc.py,sha256=xVhh9DenHHVJqF6DR6zP2GbX9JzHTlsUf0jqNQQAUbA,11479
|
||||
dashvector/core/group.py,sha256=xt9OnnAEB_P5xKG5TZmwqu38hbA3DJwGrzPAa4NFLA0,3595
|
||||
dashvector/core/handler/__init__.py,sha256=ZiiWcXjS5x0Ov_ATOcVUgW2pH1dqRUbNdZl2MLXKJGg,671
|
||||
dashvector/core/handler/__pycache__/__init__.cpython-312.pyc,,
|
||||
dashvector/core/handler/__pycache__/grpc_handler.cpython-312.pyc,,
|
||||
dashvector/core/handler/__pycache__/http_handler.cpython-312.pyc,,
|
||||
dashvector/core/handler/grpc_handler.py,sha256=S0TH4tKsgTzK8RXFZJjpBcCcRpac3Dd9OGUKzBuWZ-I,18540
|
||||
dashvector/core/handler/http_handler.py,sha256=cdc_Na6vQ-oeZ8tly3UwFVZj41Scu8aVS_gnmPjEUXo,19913
|
||||
dashvector/core/models/__init__.py,sha256=ZiiWcXjS5x0Ov_ATOcVUgW2pH1dqRUbNdZl2MLXKJGg,671
|
||||
dashvector/core/models/__pycache__/__init__.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/collection_meta_status.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/create_collection_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/create_partition_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/delete_collection_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/delete_doc_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/delete_partition_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/describe_collection_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/describe_partition_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/fetch_doc_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/get_version_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/list_collections_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/list_partitions_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/partition_meta_status.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/query_doc_group_by_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/query_doc_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/stats_collection_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/stats_partition_request.cpython-312.pyc,,
|
||||
dashvector/core/models/__pycache__/upsert_doc_request.cpython-312.pyc,,
|
||||
dashvector/core/models/collection_meta_status.py,sha256=Ym7gH-Pr3W_OD60zP9fZsU6oRrHJZ4rurEfDn6Ux6ok,10376
|
||||
dashvector/core/models/create_collection_request.py,sha256=xrX3iOV_zQAdOiRnS7WpHB2qfv51Xc1oZSeAL7ZlyJg,3782
|
||||
dashvector/core/models/create_partition_request.py,sha256=K0A4KvF30MSodL6JdYfwtZgHWIHmg2B0L-8rQwg3q_4,1778
|
||||
dashvector/core/models/delete_collection_request.py,sha256=T5A2wPyR6byhcB6BU7nsE4AVOL3ODpJ7Rzthvzt3rRk,1439
|
||||
dashvector/core/models/delete_doc_request.py,sha256=j5MxSIYiZXXp3Upl_eXz_H0G715LimATCo7PV2mfHW4,5058
|
||||
dashvector/core/models/delete_partition_request.py,sha256=ysj_2nGkn4p913gHqkPOEsmLcsw55ZaiY6Xuuf_Fe3o,1705
|
||||
dashvector/core/models/describe_collection_request.py,sha256=eK94qr-UIwFF1_coH78RlilSQojXKTKki818G0HA0Ow,1451
|
||||
dashvector/core/models/describe_partition_request.py,sha256=s74-nN68v5mJkoc4VjPOaVQv9MrFE9CrOUSHcA_E0UM,1724
|
||||
dashvector/core/models/fetch_doc_request.py,sha256=Ng-lC6104LTjb2DOB6LBwboc3tQGB3pW6u0IglcDKg4,2433
|
||||
dashvector/core/models/get_version_request.py,sha256=O1qsriTI20hE2Xz9W0hwuy5ZA2FkcApgnACbB9QSAvQ,1020
|
||||
dashvector/core/models/list_collections_request.py,sha256=nKchTHSOvACL3fuJ2A7ZTKxlKmHdxkOncoVsYPBLC9A,1029
|
||||
dashvector/core/models/list_partitions_request.py,sha256=PHQLeYz1fSxDsvjbXQSl8NYoe1zkXISEbaqiLCR-Buk,1477
|
||||
dashvector/core/models/partition_meta_status.py,sha256=RG8WjBVW5eU_YPTiq_BSN4TEKy7Oo6v_ALmaHwkFtiw,1662
|
||||
dashvector/core/models/query_doc_group_by_request.py,sha256=8KKauNmdu2g0cqPlxSrHsB_50hD4rJ93jFQWzHcq8dg,8649
|
||||
dashvector/core/models/query_doc_request.py,sha256=Wq7ouh-6ODQqgYcgtPB4LnkPdIjumN7yb6njAMqr-eI,8854
|
||||
dashvector/core/models/stats_collection_request.py,sha256=g5TRqsYxD3T-6F3IxWy8qfeC_fWadBmD30i17gXgY84,1418
|
||||
dashvector/core/models/stats_partition_request.py,sha256=ywP8PPKd9RIbavC-TpKV1pKn-syCTjuc2-a0SR-BcrQ,1708
|
||||
dashvector/core/models/upsert_doc_request.py,sha256=pMwR6iKhLnCLtgUbu3w5qyyts6JT4KNG6ob8DMLWlOY,22570
|
||||
dashvector/core/proto/__init__.py,sha256=ZiiWcXjS5x0Ov_ATOcVUgW2pH1dqRUbNdZl2MLXKJGg,671
|
||||
dashvector/core/proto/__pycache__/__init__.cpython-312.pyc,,
|
||||
dashvector/core/proto/__pycache__/dashvector_pb2.cpython-312.pyc,,
|
||||
dashvector/core/proto/__pycache__/dashvector_pb2_grpc.cpython-312.pyc,,
|
||||
dashvector/core/proto/dashvector_pb2.py,sha256=sO-oxeiB1juxZaN6rz5qF3fnld3ASO_pJD45ye753u4,31890
|
||||
dashvector/core/proto/dashvector_pb2.pyi,sha256=LVHOUH4XBJp9Wogb9t9Q3dVl_hRCzFGCt8VkH8iwu9w,88531
|
||||
dashvector/core/proto/dashvector_pb2_grpc.py,sha256=WSvhrBt38pfXe9OrZwlV3P1xLd5c_KeraFba8Npysl0,33811
|
||||
dashvector/util/__init__.py,sha256=ZiiWcXjS5x0Ov_ATOcVUgW2pH1dqRUbNdZl2MLXKJGg,671
|
||||
dashvector/util/__pycache__/__init__.cpython-312.pyc,,
|
||||
dashvector/util/__pycache__/convertor.cpython-312.pyc,,
|
||||
dashvector/util/__pycache__/validator.cpython-312.pyc,,
|
||||
dashvector/util/convertor.py,sha256=C9brkgn-nufst7B-PP77IJHYVWPOUGlXkceuUMVzRbM,1557
|
||||
dashvector/util/validator.py,sha256=kGGcWPupMA-M08J7VoxOeSkpCILNtPi1NxLFzB4A0kY,2769
|
||||
dashvector/version.py,sha256=MbZJUWjlP-w6sLfx1x_AKSxiseuYZVdIOvZmqlq2dAc,747
|
||||
4
venv/Lib/site-packages/dashvector-1.0.22.dist-info/WHEEL
Normal file
4
venv/Lib/site-packages/dashvector-1.0.22.dist-info/WHEEL
Normal file
@@ -0,0 +1,4 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: poetry-core 1.9.0
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
Reference in New Issue
Block a user