pgvector client
Project description
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. This guide will help you get started with using vecs.
If you don't have a Postgres database with the pgvector ready, see hosting for easy options.
Installation
Requires:
- Python 3.7+
You can install vecs using pip:
pip install vecs
Usage
Visit the quickstart guide for more complete info.
import vecs
DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"
# 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"]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
vecs-0.4.4.tar.gz
(22.0 kB
view details)
File details
Details for the file vecs-0.4.4.tar.gz
.
File metadata
- Download URL: vecs-0.4.4.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e03491c05a47484a33b32d6ec1d9f4841116ba7307ed9994510678f098316fd |
|
MD5 | 46e82b2c4ba925f00bd9c5f7c432c6a2 |
|
BLAKE2b-256 | 36f1758df5305ae4a5de38f645f74a8e297771f1bf7878e073e60482f95d767f |