Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert renaming vector to pgvector on the client #25911

Merged
merged 6 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes the issue that the vector extension card link wasn't being displayed.

"comment": "vector data type with similarity search",
"tags": ["AI", "Data Type", "Search"],
"link": "/guides/database/extensions/pgvector"
Expand Down