Supabaseegor_romanov,paul_copplestoneTutorial
ChatGPT plugins now support Postgres & Supabase
Summary
Retrieval plugins let ChatGPT access relevant content from private datasets by chunking documents, generating embeddings with OpenAI’s text-embedding-ada-002, and querying a vector database. The article describes Postgres and Supabase datastore implementations using pgvector, with a shared documents schema and a match_page_sections function that filters by source, author, document, and date before ranking vectors with inner product distance. It then gives a local example: downloading the Postgres 15 documentation as a PDF, uploading it through the plugin’s /upsert-file endpoint, and configuring environment variables for Supabase or Postgres. The example produced 7,904 document records, and an optional IVFFlat index can trade exact nearest-neighbor search for approximate search; after registering the local plugin in ChatGPT, users can ask questions answered from the documentation.
Context
ChatGPT needs a way to answer questions using private or external datasets. Retrieval plugins provide access to sources such as PDFs, Confluence, and Notion knowledge bases by retrieving relevant information during conversations.
Approach / What changed
The implementation adds Postgres and Supabase as vector datastore options for the ChatGPT Retrieval Plugin using pgvector. Postgres connects through psycopg2, while Supabase uses PostgREST. The tutorial creates the shared documents schema and match_page_sections function, configures the plugin, uploads the Postgres documentation, and registers the local plugin with ChatGPT.
Takeaways
The Postgres datastore uses psycopg2 for direct database access, while the Supabase datastore uses PostgREST, which supports Row Level Security and use of the data beyond ChatGPT.
The shared match_page_sections function filters records by source, author, document, and date, then finds nearest embeddings with the inner product distance function and returns a similarity score.
Uploading the Postgres documentation created 7,904 document records. An IVFFlat index can speed searches, but changes exact nearest-neighbor search to approximate nearest-neighbor search.
Source and freshness
- Source
- supabase.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.