Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

separate python/js ai docs

Oliver Rice3d86630f245e
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index 9498cbe2ac4..2fe63d684ad 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -964,34 +964,9 @@ export const ai = {
url: '/guides/ai/structured-unstructured',
},
{
- name: 'Quickstarts',
- url: undefined,
- items: [
- { name: 'Developing locally with Vecs', url: '/guides/ai/vecs-python-client' },
- { name: 'Creating and managing collections', url: '/guides/ai/quickstarts/hello-world' },
- {
- name: 'Generate Embeddings',
- url: '/guides/ai/quickstarts/generate-text-embeddings',
- },
- { name: 'Text Deduplication', url: '/guides/ai/quickstarts/text-deduplication' },
- { name: 'Face similarity search', url: '/guides/ai/quickstarts/face-similarity' },
- ],
- },
- {
- name: 'Python Client',
+ name: 'Learn',
url: undefined,
items: [
- { name: 'API', url: '/guides/ai/python/api' },
- { name: 'Collections', url: '/guides/ai/python/collections' },
- { name: 'Indexes', url: '/guides/ai/python/indexes' },
- { name: 'Metadata', url: '/guides/ai/python/metadata' },
- ],
- },
- {
- name: 'Guides',
- url: undefined,
- items: [
- { name: 'Managing collections', url: '/guides/ai/managing-collections' },
{ name: 'Vector columns', url: '/guides/ai/vector-columns' },
{ name: 'Vector indexes', url: '/guides/ai/vector-indexes', items: vectorIndexItems },
{ name: 'Engineering for scale', url: '/guides/ai/engineering-for-scale' },
@@ -1000,25 +975,23 @@ export const ai = {
],
},
{
- name: 'Examples',
+ name: 'JavaScript Examples',
url: undefined,
items: [
{
name: 'OpenAI completions using Edge Functions',
url: '/guides/ai/examples/openai',
},
- {
- name: 'Image search with OpenAI CLIP',
- url: '/guides/ai/examples/image-search-openai-clip',
- },
+
{
name: 'Generate image captions using Hugging Face',
url: '/guides/ai/examples/huggingface-image-captioning',
},
{
- name: 'Building ChatGPT Plugins',
- url: '/guides/ai/examples/building-chatgpt-plugins',
+ name: 'Generate Embeddings',
+ url: '/guides/ai/quickstarts/generate-text-embeddings',
},
+
{
name: 'Adding generative Q&A to your documentation',
url: '/guides/ai/examples/headless-vector-search',
@@ -1029,6 +1002,36 @@ export const ai = {
},
],
},
+ {
+ name: 'Python Client',
+ url: undefined,
+ items: [
+ { name: 'Choosing a Client', url: '/guides/ai/python-clients' },
+ { name: 'API', url: '/guides/ai/python/api' },
+ { name: 'Collections', url: '/guides/ai/python/collections' },
+ { name: 'Indexes', url: '/guides/ai/python/indexes' },
+ { name: 'Metadata', url: '/guides/ai/python/metadata' },
+ ],
+ },
+ {
+ name: 'Python Examples',
+ url: undefined,
+ items: [
+ { name: 'Developing locally with Vecs', url: '/guides/ai/vecs-python-client' },
+ { name: 'Creating and managing collections', url: '/guides/ai/quickstarts/hello-world' },
+
+ { name: 'Text Deduplication', url: '/guides/ai/quickstarts/text-deduplication' },
+ { name: 'Face similarity search', url: '/guides/ai/quickstarts/face-similarity' },
+ {
+ name: 'Image search with OpenAI CLIP',
+ url: '/guides/ai/examples/image-search-openai-clip',
+ },
+ {
+ name: 'Building ChatGPT Plugins',
+ url: '/guides/ai/examples/building-chatgpt-plugins',
+ },
+ ],
+ },
{
name: 'Third-Party Tools',
url: undefined,
diff --git a/apps/docs/pages/guides/ai/managing-collections.mdx b/apps/docs/pages/guides/ai/managing-collections.mdx
deleted file mode 100644
index fc56a8ae249..00000000000
--- a/apps/docs/pages/guides/ai/managing-collections.mdx
+++ /dev/null
@@ -1,156 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- id: 'ai-collections',
- title: 'Managing collections',
- description: 'Learn how to manage groups of vector records using the vecs Python library',
- sidebar_label: 'Managing collections',
-}
-
-A collection is a group of vector records managed by the `vecs` Python library. Records can be added to or updated in a collection. Collections can be queried at any time, but should be indexed for scalable query performance.
-
-Supabase provides a [Python client](/docs/guides/ai/vecs-python-client) called `vecs` for managing unstructured vector stores in Postgres. If you come from a data science background, this unstructured data approach will feel familiar. If you are more interested in a structured data approach, see [Vector columns](/docs/guides/ai/vector-columns) or read our guide on [Structured & Unstructured Embeddings](/docs/guides/ai/structured-unstructured).
-
-Under the hood `vecs` will manage the necessary Postgres tables and columns to store and query your collections.
-
-## API
-
-Find the full API in the [official API docs](https://supabase.github.io/vecs/api).
-
-### Connecting
-
-Before you can interact with vecs, create the client to communicate with Postgres.
-
-```python
-import vecs
-
-DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"
-
-# create vector store client
-vx = vecs.create_client(DB_CONNECTION)
-```
-
-### Create collection
-
-You can create a collection to store vectors specifying the collection's name and the number of dimensions in the vectors you intend to store.
-
-```python
-docs = vx.create_collection(name="docs", dimension=3)
-```
-
-If another collection exists with the same name,
-
-### Get an existing collection
-
-To access a previously created collection, use `get_collection` to retrieve it by name
-
-```python
-docs = vx.get_collection(name="docs")
-```
-
-### Upserting vectors
-
-`vecs` combines the concepts of "insert" and "update" into "upsert". Upserting records adds them to the collection if the `id` is not present, or updates the existing record if the `id` does exist.
-
-```python
-# add records to the collection
-docs.upsert(
- vectors=[
- (
- "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}
- )
- ]
-)
-```
-
-### Create an index
-
-Collections can be queried immediately after being created.
-However, for good performance, the collection should be indexed after records have been upserted.
-
-Indexes should be created **after** the collection has been populated with records. Building an index on an empty collection will significantly reduce recall. Once the index has been created you can still upsert new documents into the collection but you should rebuild the index if the size of the collection more than doubles.
-
-Only one index may exist per-collection. By default, creating an index will replace any existing index.
-
-To create an index:
-
-```python
-##
-# INSERT RECORDS HERE
-##
-
-# index the collection to be queried by cosine distance
-docs.create_index(measure=vecs.IndexMeasure.cosine_distance)
-```
-
-Available options for query `measure` are:
-
-- `vecs.IndexMeasure.cosine_distance`
-- `vecs.IndexMeasure.l2_distance`
-- `vecs.IndexMeasure.max_inner_product`
-
-which correspond to different methods for comparing query vectors to the vectors in the database.
-
-If you aren't sure which to use, stick with the default (cosine_distance) by omitting the parameter i.e.: `docs.create_index()`.
-
-<Admonition type="note">
-
-The time required to create an index grows with the number of records and size of vectors. For a few thousand records expect sub-minute a response in under a minute. It may take a few minutes for larger collections.
-
-</Admonition>
-
-For an in-depth guide on vector indexes, see [Vector indexes](/docs/guides/ai/vector-indexes).
-
-### Query
-
-Be aware that indexes are essential for good performance. If you do not create an index, every query will return a warning that includes the `IndexMeasure` you should index.
-
-#### Basic
-
-The simplest form of search is to provide a query vector.
-
-```python
-docs.query(
- query_vector=[0.4,0.5,0.6], # required
- limit=5, # number of records to return
- filters={}, # metadata filters
- measure="cosine_distance", # distance measure to use
- include_value=False, # should distance measure values be returned?
- include_metadata=False, # should record metadata be returned?
-)
-```
-
-Which returns a list of vector record `ids`.
-
-#### Metadata Filtering
-
-The metadata that is associated with each record can also be filtered during a query.
-
-As an example, `{"year": {"$eq": 2005}}` filters a `year` metadata key to be equal to 2005
-
-In context:
-
-```python
-docs.query(
- query_vector=[0.4,0.5,0.6],
- filters={"year": {"$eq": 2012}}, # metadata filters
-)
-```
-
-For a complete reference, see the [metadata guide](https://supabase.github.io/vecs/concepts_metadata/).
-
-## Resources
-
-- Official Vecs Documentation: https://supabase.github.io/vecs/api
-- Source Code: https://github.com/supabase/vecs
-
-export const Page = ({ children }) => <Layout meta={meta} children={children} />
-
-export default Page
diff --git a/apps/docs/pages/guides/ai/python-clients.mdx b/apps/docs/pages/guides/ai/python-clients.mdx
new file mode 100644
index 00000000000..5daeb28b610
--- /dev/null
+++ b/apps/docs/pages/guides/ai/python-clients.mdx
@@ -0,0 +1,18 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'ai-python-clients',
+ title: 'Choosing a Client',
+ description: 'Learn how to manage vectors using Python',
+ sidebar_label: 'Choosing a Client',
+}
+
+As described in [Structured & Unstructured Embeddings](/docs/guides/ai/structured-unstructured), AI workloads come in many forms.
+
+For data science or ephemeral workloads, the [Supabase Vecs](https://supabase.github.io/vecs/) client gets you started quickly. All you need is a connection string and vecs handles setting up your database to store and query vectors with associated metadata.
+
+For production python applications with version controled migrations, we recommend adding first class vector support to your toolchain by [registering the vector type with your ORM](https://github.com/pgvector/pgvector-python). pgvector provides bindings for the most commonly used SQL drivers/libraries including Django, SQLAlchemy, SQLModel, psycopg, asyncpg and Peewee.
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --git a/apps/docs/pages/guides/ai/vecs-python-client.mdx b/apps/docs/pages/guides/ai/vecs-python-client.mdx
index bdcecb77c43..ce7e5a7517c 100644
--- a/apps/docs/pages/guides/ai/vecs-python-client.mdx
+++ b/apps/docs/pages/guides/ai/vecs-python-client.mdx
@@ -79,7 +79,7 @@ docs.query(
## Deep Dive
-For a more in-depth guide on `vecs` collections, see [Managing collections](/docs/guides/ai/managing-collections).
+For a more in-depth guide on `vecs` collections, see [API](/docs/guides/ai/python/api).
## Resources
diff --git a/apps/docs/pages/guides/ai/vector-columns.mdx b/apps/docs/pages/guides/ai/vector-columns.mdx
index 4cfa8259708..51e995ccdcf 100644
--- a/apps/docs/pages/guides/ai/vector-columns.mdx
+++ b/apps/docs/pages/guides/ai/vector-columns.mdx
@@ -7,7 +7,7 @@ export const meta = {
sidebar_label: 'Vector columns',
}
-Supabase offers a number of different ways to store and query vectors within Postgres. If you prefer to use Python to store and query your vectors using collections, see [Managing collections](/docs/guides/ai/managing-collections). If you want more control over vectors within your own Postgres tables or would like to interact with them using a different language like JavaScript, keep reading.
+Supabase offers a number of different ways to store and query vectors within Postgres. The SQL included in this guide is applicable for clients in all programming languages. If you are a python user see your [python client options](/docs/guides/ai/python-clients) after reading the `Learn` section.
Vectors in Supabase are enabled via [pgvector](https://github.com/pgvector/pgvector/), a PostgreSQL extension for storing and querying vectors in Postgres. It can be used to store [embeddings](/docs/guides/ai/concepts#what-are-embeddings).
diff --git a/apps/docs/pages/guides/ai/vector-indexes.mdx b/apps/docs/pages/guides/ai/vector-indexes.mdx
index 041e33a02cb..2bb3a4e310e 100644
--- a/apps/docs/pages/guides/ai/vector-indexes.mdx
+++ b/apps/docs/pages/guides/ai/vector-indexes.mdx
@@ -30,8 +30,6 @@ Indexes can be used to improve performance of nearest neighbor search using vari
Currently vectors with up to 2,000 dimensions can be indexed.
-If you are using the `vecs` Python library, follow the instructions in [Managing collections](/docs/guides/ai/managing-collections#create-an-index) to create indexes.
-
## Resources
Read more about indexing on `pgvector`'s [GitHub page](https://github.com/pgvector/pgvector#indexing).