Skip to content

Commit

Permalink
fix: revert renaming vector to pgvector on the client (#25911)
Browse files Browse the repository at this point in the history
* Revert "docs: rename vector to pgvector (#23308)"

This reverts commit c30d5f0.

* Revert "docs: update vector reference to pgvector (#23305)"

This reverts commit b2bae13.

* Revert "Fix vector extension (#23386)"

This reverts commit 7341b30.

* Revert "Rename vector to pgvector on client side (#23286)"

This reverts commit b48b6e2.

* docs: add note to pgvector docs that ext name is vector

* fix: add link to vector ext card
  • Loading branch information
w3b6x9 committed May 10, 2024
1 parent fc99675 commit db24eb2
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 26 deletions.
6 changes: 3 additions & 3 deletions apps/docs/content/guides/ai/vector-columns.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ Vectors in Supabase are enabled via [pgvector](https://github.com/pgvector/pgvec

1. Go to the [Database](https://supabase.com/dashboard/project/_/database/tables) page in the Dashboard.
2. Click on **Extensions** in the sidebar.
3. Search for "pgvector" and enable the extension.
3. Search for "vector" and enable the extension.

</TabPanel>
<TabPanel id="sql" label="SQL">

```sql
-- Example: enable the pgvector extension.
-- Example: enable the "vector" extension.
create extension vector
with
schema extensions;

-- Example: disable the pgvector extension
-- Example: disable the "vector" extension
drop
extension if exists vector;
```
Expand Down
12 changes: 9 additions & 3 deletions apps/docs/content/guides/database/extensions/pgvector.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ description: 'pgvector: a PostgreSQL extension for storing embeddings and perfor

[pgvector](https://github.com/pgvector/pgvector/) is a PostgreSQL extension for vector similarity search. It can also be used for storing [embeddings](https://supabase.com/blog/openai-embeddings-postgres-vector).

<Admonition type="note">

The name of pgvector's Postgres extension is [vector](https://github.com/pgvector/pgvector/blob/258eaf58fdaff1843617ff59ea855e0768243fe9/README.md?plain=1#L64).

</Admonition>

Learn more about Supabase's [AI & Vector](/docs/guides/ai) offering.

## Concepts
Expand Down Expand Up @@ -33,18 +39,18 @@ This is particularly useful if you're building on top of OpenAI's [GPT-3](https:

1. Go to the [Database](https://supabase.com/dashboard/project/_/database/tables) page in the Dashboard.
2. Click on **Extensions** in the sidebar.
3. Search for "pgvector" and enable the extension.
3. Search for "vector" and enable the extension.

</TabPanel>
<TabPanel id="sql" label="SQL">

```sql
-- Example: enable the pgvector extension.
-- Example: enable the "vector" extension.
create extension vector
with
schema extensions;

-- Example: disable the pgvector extension
-- Example: disable the "vector" extension
drop
extension if exists vector;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from 'next/link'
import { useState } from 'react'
import toast from 'react-hot-toast'
import { extensions } from 'shared-data'
import { Badge, IconExternalLink, IconLoader, Toggle } from 'ui'
import { Badge, IconExternalLink, IconLoader, Modal, Toggle } from 'ui'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'

import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
Expand Down Expand Up @@ -72,7 +72,7 @@ const ExtensionCard = ({ extension }: ExtensionCardProps) => {
title={extension.name}
className="h-5 m-0 text-sm truncate cursor-pointer text-foreground"
>
{extension.altName || extension.name}
{extension.name}
</h3>
<p className="text-sm text-foreground-light">
{extension?.installed_version ?? extension.default_version}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ export const HIDDEN_EXTENSIONS = [
'xml2',
'pg_tle',
]

export const SEARCH_TERMS: Record<string, string[]> = {
vector: ['pgvector', 'pg_vector'],
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useDatabaseExtensionsQuery } from 'data/database-extensions/database-ex
import { useCheckPermissions, usePermissionsLoaded } from 'hooks'
import ExtensionCard from './ExtensionCard'
import ExtensionCardSkeleton from './ExtensionCardSkeleton'
import { HIDDEN_EXTENSIONS } from './Extensions.constants'
import { HIDDEN_EXTENSIONS, SEARCH_TERMS } from './Extensions.constants'

const Extensions = () => {
const { filter } = useParams()
Expand All @@ -25,17 +25,16 @@ const Extensions = () => {
connectionString: project?.connectionString,
})

const formattedExtensions = (data ?? []).map((ext) => {
if (ext.name === 'vector') return { ...ext, altName: 'pgvector' }
else return ext
})

const extensions =
filterString.length === 0
? formattedExtensions
: formattedExtensions.filter((ext) =>
(ext?.altName ?? ext.name).toLowerCase().includes(filterString.toLowerCase())
)
? data ?? []
: (data ?? []).filter((ext) => {
const nameMatchesSearch = ext.name.toLowerCase().includes(filterString.toLowerCase())
const searchTermsMatchesSearch = (SEARCH_TERMS[ext.name] || []).some((x) =>
x.includes(filterString.toLowerCase())
)
return nameMatchesSearch || searchTermsMatchesSearch
})
const extensionsWithoutHidden = extensions.filter((ext) => !HIDDEN_EXTENSIONS.includes(ext.name))
const [enabledExtensions, disabledExtensions] = partition(
extensionsWithoutHidden,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ import { UseQueryOptions, useQuery } from '@tanstack/react-query'
import { get } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseExtensionsKeys } from './keys'
import { components } from 'api-types'

export type DatabaseExtensionsVariables = {
projectRef?: string
connectionString?: string
}

export type Extension = components['schemas']['PostgresExtension']
export interface DatabaseExtension extends Extension {
altName?: string
}

export async function getDatabaseExtensions(
{ projectRef, connectionString }: DatabaseExtensionsVariables,
signal?: AbortSignal
Expand All @@ -37,7 +31,7 @@ export async function getDatabaseExtensions(
})

if (error) throw error
return data as DatabaseExtension[]
return data
}

export type DatabaseExtensionsData = Awaited<ReturnType<typeof getDatabaseExtensions>>
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-data/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@
"link": "/guides/database/extensions/uuid-ossp"
},
{
"name": "pgvector",
"name": "vector",
"comment": "vector data type with similarity search",
"tags": ["AI", "Data Type", "Search"],
"link": "/guides/database/extensions/pgvector"
Expand Down

0 comments on commit db24eb2

Please sign in to comment.