← all repositories
gannonh/chatgpt-pgvector

When ChatGPT hallucinates, feed it Postgres vectors

A Next.js starter app that stops ChatGPT from hallucinating on your documentation by retrieving relevant chunks from a Supabase vector database before it answers.

936 stars TypeScript RAG · SearchChat Assistants
chatgpt-pgvector
Not currently ranked — collecting fresh signals.
star history

What it does This Next.js boilerplate builds a retrieval-augmented chat interface over your own documentation. It scrapes web pages, splits them into 1000-character chunks, and stores OpenAI embeddings in a Supabase Postgres table using the pgvector extension. When a user asks a question, the app queries those vectors for the most similar chunks, stuffs them into the prompt alongside the source URLs, and streams back a GPT-3.5 or GPT-4 response.

The interesting bit The project is essentially a plumbing diagram for a common problem: ChatGPT makes things up and never cites sources. The fix is deliberately unglamorous—chunk text, embed it with text-embedding-ada-002, run a SQL similarity function in Postgres, and prepend the results to the system prompt. It treats the LLM as a summarization layer on top of a search engine, which is exactly what many domain-specific bots need.

Key highlights

  • Stores embeddings and performs similarity search directly in Supabase Postgres via pgvector, avoiding a dedicated vector database.
  • Preserves source URLs from scraped pages and includes them in the prompt context, letting the model attribute its answers.
  • Streams the final GPT response to the frontend for a ChatGPT-like feel.
  • Splits scraped text into 1000-character documents to stay within embedding token limits.
  • Exposes the matching logic as a native Postgres function using the <=> cosine-distance operator.

Caveats

  • The README itself misspells the project name (“ChatGTP”), which hints at casual maintenance.
  • Requires a Supabase project created after February 2023 because pgvector support is relatively new.
  • This is fundamentally glue code—useful wiring between Next.js, OpenAI, and Supabase, not a novel retrieval algorithm.

Verdict Grab this if you need a minimal, transparent RAG example without extra framework bloat. Pass if you’re looking for advanced reranking, multi-modal search, or a production-hardened ingestion pipeline.

Frequently asked

What is gannonh/chatgpt-pgvector?
A Next.js starter app that stops ChatGPT from hallucinating on your documentation by retrieving relevant chunks from a Supabase vector database before it answers.
Is chatgpt-pgvector open source?
Yes — gannonh/chatgpt-pgvector is an open-source project tracked on heatdrop.
What language is chatgpt-pgvector written in?
gannonh/chatgpt-pgvector is primarily written in TypeScript.
How popular is chatgpt-pgvector?
gannonh/chatgpt-pgvector has 936 stars on GitHub.
Where can I find chatgpt-pgvector?
gannonh/chatgpt-pgvector is on GitHub at https://github.com/gannonh/chatgpt-pgvector.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.