The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Bring in changes from master
Joshen Lim9c817b229650
diff --cc package-lock.jsonindex a6a249fb4a3,67067295f21..24455884d80--- a/package-lock.json+++ b/package-lock.json@@@ -64627,9 -65994,7 +65996,9 @@@"@storybook/testing-library": "^0.0.9","@stripe/react-stripe-js": "^1.7.0","@stripe/stripe-js": "^1.25.0",+ "@supabase/auth-helpers-nextjs": "^0.5.6",+ "@supabase/auth-helpers-react": "^0.3.1",- "@supabase/postgres-meta": "^0.60.7",+ "@supabase/postgres-meta": "^0.62.0","@supabase/react-data-grid": "^7.1.0-beta.7","@supabase/shared-types": "^0.1.40","@supabase/supabase-js": "^2.13.0",diff --cc studio/components/interfaces/SQLEditor/SQLEditor.constants.tsindex 5c98c1d5440,49dec8330ed..e610754d84d--- a/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts+++ b/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts@@@ -1072,19 -1071,90 +1072,105 @@@ selecsum(heap_blks_hit) / nullif(sum(heap_blks_hit) + sum(heap_blks_read),0) as ratiofrom pg_statio_user_tables;`,},+ {+ id: 20,+ type: 'quickstart',+ title: 'OpenAI Vector Search',+ description: 'Template for the Next.js OpenAI Doc Search Starter.',+ sql: `+ -- Enable pg_vector extension+ create extension if not exists vector with schema public;++ -- Create tables+ create table "public"."nods_page" (+ id bigserial primary key,+ parent_page_id bigint references public.nods_page,+ path text not null unique,+ checksum text,+ meta jsonb,+ type text,+ source text+ );+ alter table "public"."nods_page" enable row level security;++ create table "public"."nods_page_section" (+ id bigserial primary key,+ page_id bigint not null references public.nods_page on delete cascade,+ content text,+ token_count int,+ embedding vector(1536),+ slug text,+ heading text+ );+ alter table "public"."nods_page_section" enable row level security;++ -- Create embedding similarity search functions+ create or replace function match_page_sections(embedding vector(1536), match_threshold float, match_count int, min_content_length int)+ returns table (id bigint, page_id bigint, slug text, heading text, content text, similarity float)+ language plpgsql+ as $$+ #variable_conflict use_variable+ begin+ return query+ select+ nods_page_section.id,+ nods_page_section.page_id,+ nods_page_section.slug,+ nods_page_section.heading,+ nods_page_section.content,+ (nods_page_section.embedding <#> embedding) * -1 as similarity+ from nods_page_section++ -- We only care about sections that have a useful amount of content+ where length(nods_page_section.content) >= min_content_length++ -- The dot product is negative because of a Postgres limitation, so we negate it+ and (nods_page_section.embedding <#> embedding) * -1 > match_threshold++ -- OpenAI embeddings are normalized to length 1, so+ -- cosine similarity and dot product will produce the same results.+ -- Using dot product which can be computed slightly faster.+ --+ -- For the different syntaxes, see https://github.com/pgvector/pgvector+ order by nods_page_section.embedding <#> embedding++ limit match_count;+ end;+ $$;++ create or replace function get_page_parents(page_id bigint)+ returns table (id bigint, parent_page_id bigint, path text, meta jsonb)+ language sql+ as $$+ with recursive chain as (+ select *+ from nods_page+ where id = page_id++ union all++ select child.*+ from nods_page as child+ join chain on chain.parent_page_id = child.id+ )+ select id, parent_page_id, path, meta+ from chain;+ $$;+ `.trim(),+ },]++export const SQL_SNIPPET_SCHEMA_VERSION = '1.0'++export const NEW_SQL_SNIPPET_SKELETON: UserContent<SqlSnippets.Content> = {+ name: 'New Query',+ description: '',+ type: 'sql',+ visibility: 'user', // default to user scope+ content: {+ schema_version: SQL_SNIPPET_SCHEMA_VERSION,+ content_id: '',+ sql: 'this is a test',+ favorite: false,+ },+}diff --cc studio/pages/project/[ref]/editor/[id].tsxindex b07d2a557da,721f01a1f04..e96070b8b10--- a/studio/pages/project/[ref]/editor/[id].tsx+++ b/studio/pages/project/[ref]/editor/[id].tsx@@@ -17,9 -18,11 +18,12 @@@ import { TableGridEditor } from 'componimport ConfirmationModal from 'components/ui/ConfirmationModal'import { NextPageWithLayout, SchemaView } from 'types'import { JsonEditValue } from 'components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.types'- import { ProjectContextFromParamsProvider } from 'components/layouts/ProjectLayout/ProjectContext'+ import {+ ProjectContextFromParamsProvider,+ useProjectContext,+ } from 'components/layouts/ProjectLayout/ProjectContext'import { ForeignRowSelectorProps } from 'components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/ForeignRowSelector/ForeignRowSelector'+import { useTheme } from 'common'const TableEditorPage: NextPageWithLayout = () => {const router = useRouter()@@@ -261,7 -292,8 +294,8 @@@onExpandJSONEditor={onExpandJSONEditor}onEditForeignKeyColumnValue={onEditForeignKeyColumnValue}onClosePanel={onClosePanel}- theme={ui.themeOption == 'dark' ? 'dark' : 'light'}+ theme={isDarkMode ? 'dark' : 'light'}+ onImportData={onImportData}/><ConfirmationModaldanger