Headless Vector Search: An Overview
The Headless Vector Search project is designed to provide an efficient vector and similarity search capability for any documentation site, making it a perfect addition to existing websites. The headless nature of this project means it can seamlessly integrate into any web platform without the need for a front-end component.
How It Works
The project operates by setting up a new docs
schema in your database. Through the use of an associated GitHub Action, it is capable of ingesting markdown documentation into your database, turning them into embeddings. To enhance user interaction, the project also includes an Edge Function that processes user queries and transforms them into responses similar to those generated by ChatGPT.
Tech Stack
The Headless Vector Search leverages several advanced technologies to function effectively:
- Supabase: This serves as the hub for the database and Edge Functions.
- OpenAI: It provides the necessary embeddings and completions to ensure relevant search results.
- GitHub Actions: These are used to automatically ingest markdown documentation into the database.
Setting Up
To set up the Headless Vector Search, follow these steps:
- Begin by creating a new Supabase project at database.new.
- Clone the project repository to your local machine.
- Connect the cloned repository to your remote project using the command:
supabase link --project-ref XXX
. - Apply the necessary database migrations using:
supabase db push
. - Set your OpenAI API key as a secret:
supabase secrets set OPENAI_API_KEY=sk-xxx
. - Deploy the Edge Functions with:
supabase functions deploy --no-verify-jwt
. - Ensure the
docs
schema is exposed through the API by adjusting settings in the Supabase Dashboard underAPI Settings
>Exposed schemas
. - Set up the
supabase-vector-embeddings
GitHub action in your Knowledge Base repository. Once the action is executed, the embeddings will be visible in your database.
Usage
Utilizing the Headless Vector Search within an application is straightforward:
- Locate the URL for the
vector-search
Edge Function from the Functions section of the Supabase Dashboard. - Send user queries to this endpoint to receive streamed responses from OpenAI in your application.
For example, using cURL, you could perform a search like so:
curl -i --location --request GET 'https://your-project-ref.functions.supabase.co/vector-search?query=What%27s+Supabase%3F'
Additionally, by using JavaScript's EventSource, you can handle queries and listen for responses in real time, enriching the user experience.
Showcase
An example of Headless Vector Search in action can be seen on docs.supabase.com. By pressing cmd+k, users can access the search capability and explore its functionality.
License
The project is licensed under the MIT License, ensuring it is open-source and freely usable by anyone interested in implementing this powerful search feature in their own websites or applications.