https://github.com/634750802/tidb-vector-python
https://github.com/634750802/tidb-vector-python
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/634750802/tidb-vector-python
- Owner: 634750802
- Created: 2024-01-09T09:45:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-10T03:40:47.000Z (over 1 year ago)
- Last Synced: 2024-10-18T16:25:57.421Z (8 months ago)
- Language: Python
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Usage
> TiDB Vector is not released currently.
### Pre-requirements
Install TiDB Vector
```shell
$ pip install tidb-vector
```Prepare your database info and create a `.env` file in working directory
```
TIDB_HOST=
TIDB_USER=
TIDB_PASSWORD=
TIDB_PORT=4000
TIDB_DB_NAME=
```### Basic Usage
```python
from tidb_vector import VectorStore, VectorDocument# Initialize a Vector Store
vc = VectorStore()# Open or create a Vector Collection
c = vc.open_collection(name='a_cool_collection_name')# Insert documents
c.insert([
VectorDocument(
document_id='id-0',
vector=[1, 2, 4, 5, 6, 7],
content='The raw content of the document',
metadata={}
)
])# Similarity search
results = c.cosine_similarity(vector=[1, 2, 3, 4], limit=13)
for result in results:
print(result.id, result.content, result.similarity)
```