Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Supabase 7 min read How-to mediumAdept

ChatGPT plugins now support Postgres & Supabase

Supabase contributed Postgres and Supabase datastore providers to OpenAI's ChatGPT Retrieval Plugin, storing text-embedding-ada-002 embeddings in pgvector. The Postgres provider connects directly via psycopg2, while the Supabase provider goes through PostgREST to enable Row Level Security. Both share the same documents schema and use a plpgsql match function that filters by source, author and date and ranks results by inner product distance. A walkthrough ingests the PostgreSQL 15 docs (about 7,904 chunks), adds an approximate ivfflat index with lists ≈ rows/1000, and registers the local plugin with ChatGPT to answer documentation questions.

Related posts

  • Storing OpenAI embeddings in Postgres with pgvector

    Supabase mediumAdept

    pgvector adds a vector data type and distance operators (Euclidean <->, negative inner product <#>, cosine <=>) to Postgres, so OpenAI text-embedding-ada-002 embeddings (1536 dimensions) can be stored and queried for similarity directly in the database. The walkthrough creates a documents table, a match_documents SQL function that filters by a cosine-similarity threshold, and an IVFFlat index sized at roughly 4 * sqrt(rows) lists. It then generates embeddings in JavaScript and builds Deno Edge Functions for semantic search and for retrieval-augmented answers with text-davinci-003, keeping injected context under about 1500 tokens to fit the 4000-token limit.

  • Hugging Face is now supported in Supabase

    Supabase mediumAdept

    Supabase adds first-class Hugging Face support for generating embeddings stored in pgvector, as an open-source, self-hostable alternative to OpenAI's text-embedding-ada-002. The Python vecs client gains "adapters" that chunk text and embed it automatically on upsert and query. Edge Functions can run Transformers.js inference in Deno, and small models can even run in the browser and query pgvector through PostgREST and RLS. Supabase recommends lower-dimension models such as gte-small for cheaper storage and faster retrieval, and notes current limits: 2-6s cold starts from model downloads, and no turnkey audio/image decoding in Deno.

  • Build an end-to-end RAG pipeline entirely in psql using pgrag and DeepSeek

    Neon mediumAdept

    pgrag, Neon's open-source Postgres extension, lets you build a complete RAG pipeline inside psql. It provides SQL functions for PDF/DOCX/HTML text extraction, character- or token-based chunking, local CPU embeddings (bge-small-en-v1.5) and reranking (jina-reranker-v1-tiny), plus API calls to OpenAI, Voyage, Anthropic and Fireworks. Paired with pgvector HNSW indexes, a worked example indexes PGConf EU 2023 slides. A single query then retrieves the top 10 chunks, reranks them to 5, and prompts DeepSeek V3, which correctly declines out-of-scope questions. The local models ship as separate ~100MB extensions, and on Neon they need around 2GB RAM of compute.

  • Supabase Vecs: a vector client for Postgres

    Supabase mediumAdept

    Vecs is a Python client that makes Postgres with the pgvector extension behave like a dedicated vector store, handling collection (table) creation, indexing, upserts, and similarity queries by cosine, L2, or max inner product with a jsonb-backed metadata filter DSL. Each collection maps to a plain table in a `vecs` schema (text id, vector column, jsonb metadata), so users can drop down to SQL when needed. On Supabase, collections can be exposed as public views and queried from supabase-js. Possible future work includes built-in text/image embedding transforms and an async client.

  • Building a RAG application with Llama 3.1 and pgvector

    Neon mediumAdept

    A small RAG pipeline built on Neon Postgres with pgvector as the vector store, OctoAI's gte-large embedding model producing 1024-dimensional vectors, and Llama 3.1 405B generating answers. The walkthrough enables the vector extension, creates a table with a VECTOR(1024) column, and embeds and inserts a CSV of fake quotes from Python via psycopg2. At query time it embeds the user input, retrieves the two nearest quotes with a cosine-distance ORDER BY ... LIMIT 2 query, and injects them into the system prompt. Embedding dimension directly drives storage cost, e.g. 1024 for gte-large versus up to 3072 for OpenAI's model.

The quest for software engineering knowledge.

Look:
Layout: