nextjs-openai-doc-search  by supabase-community

Template for custom ChatGPT-style doc search

created 2 years ago
1,666 stars

Top 25.9% on sourcepulse

GitHubView on GitHub
Project Summary

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

  • Install/Run: pnpm dev (after setting up Supabase and environment variables).
  • Prerequisites: Docker (for supabase start), OpenAI API Key, Supabase project setup.
  • Setup: Requires cloning the repo, copying .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.
  • Docs: Blog post

Highlighted Details

  • Leverages pgvector for efficient similarity search within PostgreSQL.
  • Embeddings are generated at build time to optimize runtime performance.
  • Supports streaming responses from OpenAI.
  • Includes a mechanism to regenerate embeddings only for modified files.

Maintenance & Community

  • Project is part of the supabase-community organization.
  • Further details on community channels or roadmap are not explicitly provided in the README.

Licensing & Compatibility

  • License: Apache 2.0.
  • Compatibility: Permissive license suitable for commercial use and integration with closed-source applications.

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.

Health Check
Last commit

11 months ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
22 stars in the last 90 days

Explore Similar Projects

Starred by Jared Palmer Jared Palmer(Ex-VP of AI at Vercel; Founder of Turborepo; Author of Formik, TSDX).

chatgpt-pgvector by gannonh

0%
938
Domain-specific chat completions app
created 2 years ago
updated 2 years ago
Feedback? Help us improve.