You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As an alternative to
#63
After discussion with @JaySon-Huang, inspired by some other vector
databases, I think we could simply introduce some side functions for
creating indexes. The usage is as simple as using native SQLAlchemy
interfaces, without the need to introduce another dialect like
sqlalchemy-tidb.
Maintaining a new SQLAlchemy dialect is costy, as we need to support
both SQLAlchemy 1.4 and SQLAlchemy 2.0, and support other TiDB features
like AUTO_RANDOM.
---------
Signed-off-by: Wish <breezewish@outlook.com>
Co-authored-by: WD <me@wangdi.ink>
Copy file name to clipboardExpand all lines: README.md
+59-55Lines changed: 59 additions & 55 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,6 @@
1
1
# tidb-vector-python
2
2
3
-
This is a Python client for TiDB Vector.
4
-
5
-
> Now only TiDB Cloud Serverless cluster support vector data type, see this [docs](https://docs.pingcap.com/tidbcloud/vector-search-overview?utm_source=github&utm_medium=tidb-vector-python) for more information.
3
+
Use TiDB Vector Search with Python.
6
4
7
5
## Installation
8
6
@@ -12,74 +10,79 @@ pip install tidb-vector
12
10
13
11
## Usage
14
12
15
-
TiDB vector supports below distance functions:
13
+
TiDB is a SQL database so that this package introduces Vector Search capability for Python ORMs:
16
14
17
-
-`L1Distance`
18
-
-`L2Distance`
19
-
-`CosineDistance`
20
-
-`NegativeInnerProduct`
15
+
-[#SQLAlchemy](#sqlalchemy)
16
+
-[#Django](#django)
17
+
-[#Peewee](#peewee)
21
18
22
-
It also supports using hnsw index with l2 or cosine distance to speed up the search, for more details see [Vector Search Indexes in TiDB](https://docs.pingcap.com/tidbcloud/vector-search-index)
19
+
Pick one that you are familiar with to get started. If you are not using any of them, we recommend [#SQLAlchemy](#sqlalchemy).
23
20
24
-
Supports following orm or framework:
21
+
We also provide a Vector Search client for simple usage:
25
22
26
-
-[SQLAlchemy](#sqlalchemy)
27
-
-[Django](#django)
28
-
-[Peewee](#peewee)
29
-
-[TiDB Vector Client](#tidb-vector-client)
23
+
-[#TiDB Vector Client](#tidb-vector-client)
30
24
31
25
### SQLAlchemy
32
26
33
-
Learn how to connect to TiDB Serverless in the [TiDB Cloud documentation](https://docs.pingcap.com/tidbcloud/dev-guide-sample-application-python-sqlalchemy).
34
-
35
-
Define table with vector field
27
+
```bash
28
+
pip install tidb-vector sqlalchemy pymysql
29
+
```
36
30
37
31
```python
38
-
from sqlalchemy importColumn, Integer, create_engine
39
-
from sqlalchemy.ormimportdeclarative_base
40
-
fromtidb_vector.sqlalchemy importVectorType
32
+
from sqlalchemy importInteger, Text, Column
33
+
from sqlalchemy importcreate_engine, select
34
+
from sqlalchemy.ormimportSession, declarative_base
Within the framework, you can directly utilize the built-in `TiDBVectorClient`, as demonstrated by integrations like [Langchain](https://python.langchain.com/docs/integrations/vectorstores/tidb_vector) and [Llama index](https://docs.llamaindex.ai/en/stable/community/integrations/vector_stores.html#using-a-vector-store-as-an-index), to seamlessly interact with TiDB Vector. This approach abstracts away the need to manage the underlying ORM, simplifying your interaction with the vector store.
171
+
Within the framework, you can directly utilize the built-in `TiDBVectorClient`, as demonstrated by integrations like [Langchain](https://python.langchain.com/docs/integrations/vectorstores/tidb_vector) and [Llama index](https://docs.llamaindex.ai/en/stable/community/integrations/vector_stores.html#using-a-vector-store-as-an-index), to seamlessly interact with TiDB Vector. This approach abstracts away the need to manage the underlying ORM, simplifying your interaction with the vector store.
169
172
170
173
We provide `TiDBVectorClient` which is based on sqlalchemy, you need to use `pip install tidb-vector[client]` to install it.
171
174
@@ -252,4 +255,5 @@ There are some examples to show how to use the tidb-vector-python to interact wi
252
255
for more examples, see the [examples](./examples) directory.
253
256
254
257
## Contributing
255
-
Please feel free to reach out to the maintainers if you have any questions or need help with the project. Before contributing, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
258
+
259
+
Please feel free to reach out to the maintainers if you have any questions or need help with the project. Before contributing, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
0 commit comments