Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/supabase/vecs
Postgres/pgvector Python Client
https://github.com/supabase/vecs
ai embeddings pgvector postgres vectors
Last synced: 27 days ago
JSON representation
Postgres/pgvector Python Client
- Host: GitHub
- URL: https://github.com/supabase/vecs
- Owner: supabase
- License: apache-2.0
- Created: 2023-05-19T14:52:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-28T17:58:42.000Z (8 months ago)
- Last Synced: 2024-04-13T21:54:17.393Z (7 months ago)
- Topics: ai, embeddings, pgvector, postgres, vectors
- Language: Python
- Homepage: https://supabase.github.io/vecs/latest
- Size: 6.54 MB
- Stars: 190
- Watchers: 16
- Forks: 30
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Support: docs/support_changelog.md
Awesome Lists containing this project
README
# vecs
---
**Documentation**: https://supabase.github.io/vecs/latest/
**Source Code**: https://github.com/supabase/vecs
---
`vecs` is a python client for managing and querying vector stores in PostgreSQL with the [pgvector extension](https://github.com/pgvector/pgvector). This guide will help you get started with using vecs.
If you don't have a Postgres database with the pgvector ready, see [hosting](https://supabase.github.io/vecs/hosting/) for easy options.
## Installation
Requires:
- Python 3.7+
You can install vecs using pip:
```sh
pip install vecs
```## Usage
Visit the [quickstart guide](https://supabase.github.io/vecs/latest/api) for more complete info.
```python
import vecsDB_CONNECTION = "postgresql://:@:/"
# create vector store client
vx = vecs.create_client(DB_CONNECTION)# create a collection of vectors with 3 dimensions
docs = vx.get_or_create_collection(name="docs", dimension=3)# add records to the *docs* collection
docs.upsert(
records=[
(
"vec0", # the vector's identifier
[0.1, 0.2, 0.3], # the vector. list or np.array
{"year": 1973} # associated metadata
),
(
"vec1",
[0.7, 0.8, 0.9],
{"year": 2012}
)
]
)# index the collection for fast search performance
docs.create_index()# query the collection filtering metadata for "year" = 2012
docs.query(
data=[0.4,0.5,0.6], # required
limit=1, # number of records to return
filters={"year": {"$eq": 2012}}, # metadata filters
)# Returns: ["vec1"]
```