mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Docs: Update AI guides to reference pooler connection string (#20846)
docs(ai): update guides to reference pooler connection string
This commit is contained in:
1 parent
d29771a630
commit
d42536b23e
10 files changed
+105
-15
No files matched your search
@@ -37,7 +37,7 @@ There are 3 steps to build similarity search inside your documentation:
|
||||
|
||||
### Prepare your database
|
||||
|
||||
To prepare, create a [new Supabase project](https://database.new) and store the database and API credentials, which you can find in the project [settings](https://supabase.com/dashboard/_/settings).
|
||||
To prepare, create a [new Supabase project](https://database.new) and store the database and API credentials, which you can find in the project [settings](https://supabase.com/dashboard/project/_/settings).
|
||||
|
||||
Now we can use the [Headless Vector Search](https://github.com/supabase/headless-vector-search#set-up) instructions to set up the database:
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ pip install vecs
|
||||
|
||||
## Connect to your database
|
||||
|
||||
Find the Postgres pooler connection string for your Supabase project in the [database settings](https://supabase.com/dashboard/_/settings/database) of the dashboard. Copy the "URI" format, which should look something like `postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres`
|
||||
Find the Postgres pooler connection string for your Supabase project in the [database settings](https://supabase.com/dashboard/project/_/settings/database) of the dashboard. Copy the "URI" format, which should look something like `postgres://postgres.xxxx:password@xxxx.pooler.supabase.com:6543/postgres`
|
||||
|
||||
Create a new code block below the install block (`ctrl+m b`) and add the following code using the Postgres URI you copied above:
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Admonition } from 'ui'
|
||||
import Layout from '~/layouts/DefaultGuideLayout'
|
||||
|
||||
export const meta = {
|
||||
@@ -46,7 +47,19 @@ DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"
|
||||
vx = vecs.create_client(DB_CONNECTION)
|
||||
```
|
||||
|
||||
Replace the `DB_CONNECTION` with your own connection string for your database, which you set up in first step of this guide.
|
||||
Replace the `DB_CONNECTION` with your own connection string for your database. You can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) of your Supabase project.
|
||||
|
||||
<Admonition type='note'>
|
||||
|
||||
SQLAlchemy requires the connection string to start with `postgresql://` (instead of `postgres://`). Don't forget to rename this after copying the string from the dashboard.
|
||||
|
||||
</Admonition>
|
||||
|
||||
<Admonition type='note'>
|
||||
|
||||
You must use the "connection pooling" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6.
|
||||
|
||||
</Admonition>
|
||||
|
||||
## Stepping through the notebook
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Admonition } from 'ui'
|
||||
import Layout from '~/layouts/DefaultGuideLayout'
|
||||
|
||||
export const meta = {
|
||||
id: 'ai-vecs-python-client',
|
||||
title: 'Face similarity search',
|
||||
@@ -43,7 +43,19 @@ DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"
|
||||
vx = vecs.create_client(DB_CONNECTION)
|
||||
```
|
||||
|
||||
Replace the `DB_CONNECTION` with your own connection string for your database, which you set up in first step of this guide.
|
||||
Replace the `DB_CONNECTION` with your own connection string for your database. You can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) of your Supabase project.
|
||||
|
||||
<Admonition type='note'>
|
||||
|
||||
SQLAlchemy requires the connection string to start with `postgresql://` (instead of `postgres://`). Don't forget to rename this after copying the string from the dashboard.
|
||||
|
||||
</Admonition>
|
||||
|
||||
<Admonition type='note'>
|
||||
|
||||
You must use the "connection pooling" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6.
|
||||
|
||||
</Admonition>
|
||||
|
||||
## Stepping through the notebook
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Admonition } from 'ui'
|
||||
import Layout from '~/layouts/DefaultGuideLayout'
|
||||
|
||||
export const meta = {
|
||||
@@ -43,7 +44,19 @@ DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"
|
||||
vx = vecs.create_client(DB_CONNECTION)
|
||||
```
|
||||
|
||||
Replace the `DB_CONNECTION` with your own connection string for your database, which you set up in first step of this guide.
|
||||
Replace the `DB_CONNECTION` with your own connection string for your database. You can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) of your Supabase project.
|
||||
|
||||
<Admonition type='note'>
|
||||
|
||||
SQLAlchemy requires the connection string to start with `postgresql://` (instead of `postgres://`). Don't forget to rename this after copying the string from the dashboard.
|
||||
|
||||
</Admonition>
|
||||
|
||||
<Admonition type='note'>
|
||||
|
||||
You must use the "connection pooling" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6.
|
||||
|
||||
</Admonition>
|
||||
|
||||
## Stepping through the notebook
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Layout from '~/layouts/DefaultGuideLayout'
|
||||
import { Admonition } from 'ui'
|
||||
import HuggingFaceDeployment from '~/components/MDX/ai/quickstart_hf_deployment.mdx'
|
||||
import Layout from '~/layouts/DefaultGuideLayout'
|
||||
|
||||
export const meta = {
|
||||
id: 'ai-vecs-python-client',
|
||||
@@ -44,7 +45,19 @@ DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"
|
||||
vx = vecs.create_client(DB_CONNECTION)
|
||||
```
|
||||
|
||||
Replace the `DB_CONNECTION` with your own connection string for your database, which you set up in first step of this guide.
|
||||
Replace the `DB_CONNECTION` with your own connection string for your database. You can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) of your Supabase project.
|
||||
|
||||
<Admonition type='note'>
|
||||
|
||||
SQLAlchemy requires the connection string to start with `postgresql://` (instead of `postgres://`). Don't forget to rename this after copying the string from the dashboard.
|
||||
|
||||
</Admonition>
|
||||
|
||||
<Admonition type='note'>
|
||||
|
||||
You must use the "connection pooling" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6.
|
||||
|
||||
</Admonition>
|
||||
|
||||
## Stepping through the notebook
|
||||
|
||||
|
||||
@@ -21,6 +21,16 @@
|
||||
"We'll start by loading a dataset of celebrity faces. Then we'll create embeddings for the faces using python's `face_recognition` library and store them in PostgreSQL with `vecs`. Finally we'll query the database with a user defined face to see which celebrities they look most like."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "69e93981",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Setup GPU on Google Colab\n",
|
||||
"\n",
|
||||
"If you are running this in Google Colab, you must first ensure that the GPU is enabled. You can set this by navigating to **Runtime** > **Change runtime type**, then choose one of the available GPUs under **Hardware Accelerator**."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3cab93f5-10d0-47c5-9f4e-64921461e7e2",
|
||||
@@ -189,7 +199,15 @@
|
||||
"## Initialize the Vecs Collection\n",
|
||||
"\n",
|
||||
"The [`vecs`](https://supabase.github.io/vecs/api/) library wraps a pythonic interface around PostgreSQL and pgvector.\n",
|
||||
"A collection in `vecs` maps 1:1 with a PostgreSQL table."
|
||||
"A collection in `vecs` maps 1:1 with a PostgreSQL table.\n",
|
||||
"\n",
|
||||
"First you will need to establish a connection to your database. You can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) of your Supabase project.\n",
|
||||
"\n",
|
||||
"> **Note:** SQLAlchemy requires the connection string to start with `postgresql://` (instead of `postgres://`). Don't forget to rename this after copying the string from the dashboard.\n",
|
||||
"\n",
|
||||
"> **Note:** You must use the \"connection pooling\" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6.\n",
|
||||
"\n",
|
||||
"This will also work with any other Postgres provider that supports pgvector."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
"source": [
|
||||
"# Set up OpenAI\n",
|
||||
"\n",
|
||||
"LlamaIndex uses OpenAI GPT-3 `text-davinci-003` model. Let's store that in an environment variable:"
|
||||
"OpenAI requires an [API key](https://platform.openai.com/api-keys) to run their models. Let's store that in an environment variable:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -116,7 +116,13 @@
|
||||
"source": [
|
||||
"## Create an index in Supabase\n",
|
||||
"\n",
|
||||
"Let's store Paul Graham's essays in Supabase. You can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/_/settings/database) of your Supabase project. This will work with all Postgres providers that support pgvector."
|
||||
"Let's store Paul Graham's essays in Supabase. You can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) of your Supabase project.\n",
|
||||
"\n",
|
||||
"> **Note:** SQLAlchemy requires the connection string to start with `postgresql://` (instead of `postgres://`). Don't forget to rename this after copying the string from the dashboard.\n",
|
||||
"\n",
|
||||
"> **Note:** You must use the \"connection pooling\" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6.\n",
|
||||
"\n",
|
||||
"This will also work with any other Postgres provider that supports pgvector."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -138,7 +138,15 @@
|
||||
"## Initialize the Vecs Collection\n",
|
||||
"\n",
|
||||
"The [`vecs`](https://supabase.github.io/vecs/api/) library wraps a pythonic interface around PostgreSQL and pgvector.\n",
|
||||
"A collection in `vecs` maps 1:1 with a PostgreSQL table."
|
||||
"A collection in `vecs` maps 1:1 with a PostgreSQL table.\n",
|
||||
"\n",
|
||||
"First you will need to establish a connection to your database. You can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) of your Supabase project.\n",
|
||||
"\n",
|
||||
"> **Note:** SQLAlchemy requires the connection string to start with `postgresql://` (instead of `postgres://`). Don't forget to rename this after copying the string from the dashboard.\n",
|
||||
"\n",
|
||||
"> **Note:** You must use the \"connection pooling\" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6.\n",
|
||||
"\n",
|
||||
"This will also work with any other Postgres provider that supports pgvector."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -52,12 +52,19 @@
|
||||
"id": "AeGQKpZegfCv"
|
||||
},
|
||||
"source": [
|
||||
"##Usage\n",
|
||||
"###Connecting\n",
|
||||
"## Usage\n",
|
||||
"\n",
|
||||
"### Connecting\n",
|
||||
"\n",
|
||||
"Before you can interact with vecs, create the client to communicate with Postgres.\n",
|
||||
"\n",
|
||||
"Note: In Supabase go to [Database Settings](https://supabase.com/dashboard/project/_/settings/database) to get your Postgres connection string."
|
||||
"In Supabase, you can find the Postgres connection string in the [Database Settings](https://supabase.com/dashboard/project/_/settings/database) of your Supabase project.\n",
|
||||
"\n",
|
||||
"> **Note:** SQLAlchemy requires the connection string to start with `postgresql://` (instead of `postgres://`). Don't forget to rename this after copying the string from the dashboard.\n",
|
||||
"\n",
|
||||
"> **Note:** You must use the \"connection pooling\" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6.\n",
|
||||
"\n",
|
||||
"This will also work with any other Postgres provider that supports pgvector."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user