From d42536b23e8ebf50596d0c1eecfcaf7ecac9e16d Mon Sep 17 00:00:00 2001 From: Greg Richardson Date: Mon, 29 Jan 2024 13:44:23 -0700 Subject: [PATCH] Docs: Update AI guides to reference pooler connection string (#20846) docs(ai): update guides to reference pooler connection string --- .../ai/examples/headless-vector-search.mdx | 2 +- apps/docs/pages/guides/ai/google-colab.mdx | 2 +- .../guides/ai/integrations/llamaindex.mdx | 15 +++++++++++++- .../guides/ai/quickstarts/face-similarity.mdx | 16 +++++++++++++-- .../guides/ai/quickstarts/hello-world.mdx | 15 +++++++++++++- .../ai/quickstarts/text-deduplication.mdx | 17 ++++++++++++++-- examples/ai/face_similarity.ipynb | 20 ++++++++++++++++++- examples/ai/llamaindex/llamaindex.ipynb | 10 ++++++++-- examples/ai/semantic_text_deduplication.ipynb | 10 +++++++++- examples/ai/vector_hello_world.ipynb | 13 +++++++++--- 10 files changed, 105 insertions(+), 15 deletions(-) diff --git a/apps/docs/pages/guides/ai/examples/headless-vector-search.mdx b/apps/docs/pages/guides/ai/examples/headless-vector-search.mdx index 9267986b634..78c59abc87b 100644 --- a/apps/docs/pages/guides/ai/examples/headless-vector-search.mdx +++ b/apps/docs/pages/guides/ai/examples/headless-vector-search.mdx @@ -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: diff --git a/apps/docs/pages/guides/ai/google-colab.mdx b/apps/docs/pages/guides/ai/google-colab.mdx index ef9cb7325f5..2f6cca0ea68 100644 --- a/apps/docs/pages/guides/ai/google-colab.mdx +++ b/apps/docs/pages/guides/ai/google-colab.mdx @@ -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: diff --git a/apps/docs/pages/guides/ai/integrations/llamaindex.mdx b/apps/docs/pages/guides/ai/integrations/llamaindex.mdx index b1aa7f80b2a..23bfd749a96 100644 --- a/apps/docs/pages/guides/ai/integrations/llamaindex.mdx +++ b/apps/docs/pages/guides/ai/integrations/llamaindex.mdx @@ -1,3 +1,4 @@ +import { Admonition } from 'ui' import Layout from '~/layouts/DefaultGuideLayout' export const meta = { @@ -46,7 +47,19 @@ DB_CONNECTION = "postgresql://:@:/" 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. + + + +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. + + + + + +You must use the "connection pooling" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6. + + ## Stepping through the notebook diff --git a/apps/docs/pages/guides/ai/quickstarts/face-similarity.mdx b/apps/docs/pages/guides/ai/quickstarts/face-similarity.mdx index 160ed479b6d..36694ba9320 100644 --- a/apps/docs/pages/guides/ai/quickstarts/face-similarity.mdx +++ b/apps/docs/pages/guides/ai/quickstarts/face-similarity.mdx @@ -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://:@:/" 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. + + + +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. + + + + + +You must use the "connection pooling" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6. + + ## Stepping through the notebook diff --git a/apps/docs/pages/guides/ai/quickstarts/hello-world.mdx b/apps/docs/pages/guides/ai/quickstarts/hello-world.mdx index d612ed23d86..88d4b42ef5c 100644 --- a/apps/docs/pages/guides/ai/quickstarts/hello-world.mdx +++ b/apps/docs/pages/guides/ai/quickstarts/hello-world.mdx @@ -1,3 +1,4 @@ +import { Admonition } from 'ui' import Layout from '~/layouts/DefaultGuideLayout' export const meta = { @@ -43,7 +44,19 @@ DB_CONNECTION = "postgresql://:@:/" 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. + + + +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. + + + + + +You must use the "connection pooling" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6. + + ## Stepping through the notebook diff --git a/apps/docs/pages/guides/ai/quickstarts/text-deduplication.mdx b/apps/docs/pages/guides/ai/quickstarts/text-deduplication.mdx index d15cbbd1289..afa8cf81b49 100644 --- a/apps/docs/pages/guides/ai/quickstarts/text-deduplication.mdx +++ b/apps/docs/pages/guides/ai/quickstarts/text-deduplication.mdx @@ -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://:@:/" 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. + + + +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. + + + + + +You must use the "connection pooling" string (domain ending in `*.pooler.supabase.com`) with Google Colab since Colab does not support IPv6. + + ## Stepping through the notebook diff --git a/examples/ai/face_similarity.ipynb b/examples/ai/face_similarity.ipynb index 5a6d22a7844..706cfe20588 100644 --- a/examples/ai/face_similarity.ipynb +++ b/examples/ai/face_similarity.ipynb @@ -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." ] }, { diff --git a/examples/ai/llamaindex/llamaindex.ipynb b/examples/ai/llamaindex/llamaindex.ipynb index 8c4119761aa..6f1a26b0d65 100644 --- a/examples/ai/llamaindex/llamaindex.ipynb +++ b/examples/ai/llamaindex/llamaindex.ipynb @@ -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." ] }, { diff --git a/examples/ai/semantic_text_deduplication.ipynb b/examples/ai/semantic_text_deduplication.ipynb index 04ce6bf30d8..f05fdf4f56f 100644 --- a/examples/ai/semantic_text_deduplication.ipynb +++ b/examples/ai/semantic_text_deduplication.ipynb @@ -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." ] }, { diff --git a/examples/ai/vector_hello_world.ipynb b/examples/ai/vector_hello_world.ipynb index 1dc64dd7dc5..ab6d321052f 100644 --- a/examples/ai/vector_hello_world.ipynb +++ b/examples/ai/vector_hello_world.ipynb @@ -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." ] }, {