Template for custom ChatGPT-style doc search
Top 25.9% on sourcepulse
This template provides a starter for building a custom ChatGPT-style document search using Next.js, OpenAI, and Supabase. It's designed for developers who want to integrate their documentation into a conversational AI interface, enabling users to query information contextually.
How It Works
The system operates in two phases: build time and runtime. At build time, .mdx
files are chunked, and embeddings are generated via the OpenAI API. These embeddings are stored in a Supabase PostgreSQL database with the pgvector
extension for efficient similarity searches. A checksum mechanism ensures embeddings are only regenerated for changed files. At runtime, user queries are embedded, used to perform a vector similarity search against the stored embeddings, and the most relevant document chunks are injected into an OpenAI GPT-3 prompt for a contextualized response, streamed back to the client.
Quick Start & Requirements
pnpm dev
(after setting up Supabase and environment variables).supabase start
), OpenAI API Key, Supabase project setup..env.example
to .env
, setting OPENAI_KEY
, NEXT_PUBLIC_SUPABASE_ANON_KEY
, and SUPABASE_SERVICE_ROLE_KEY
. Running supabase start
is necessary to obtain Supabase keys and initialize the database with pgvector
.Highlighted Details
pgvector
for efficient similarity search within PostgreSQL.Maintenance & Community
supabase-community
organization.Licensing & Compatibility
Limitations & Caveats
The project relies on external services (OpenAI API, Supabase) which incur costs. The documentation processing is limited to .mdx
files by default, requiring conversion for other formats.
11 months ago
1 week