Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/supabase/headless-vector-search
Supabase Toolkit to perform vector similarity search on your knowledge base embeddings.
https://github.com/supabase/headless-vector-search
embeddings openai postgres postgresql supabase vector
Last synced: 1 day ago
JSON representation
Supabase Toolkit to perform vector similarity search on your knowledge base embeddings.
- Host: GitHub
- URL: https://github.com/supabase/headless-vector-search
- Owner: supabase
- License: mit
- Created: 2023-05-25T16:04:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-15T18:37:54.000Z (8 months ago)
- Last Synced: 2024-10-29T14:39:17.042Z (about 2 months ago)
- Topics: embeddings, openai, postgres, postgresql, supabase, vector
- Language: TypeScript
- Homepage:
- Size: 15.6 KB
- Stars: 159
- Watchers: 21
- Forks: 27
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Headless Vector Search
Provides a vector/similarity search for any documentation site. It's [headless](https://en.wikipedia.org/wiki/Headless_software), so that you can integrate it into your existing website.
#### How it works:
- This repo initializes a new `docs` schema inside your database.
- The accompanying [GitHub Action](https://github.com/supabase/supabase-vector-embeddings-github-action) ingests your markdown docs into your database as embeddings.
- This repo provides an Edge Function that handles user queries, converting them into ChatGPT-like responses.#### Tech stack:
- Supabase: Database & Edge Functions.
- OpenAI: Embeddings and completions.
- GitHub Actions: for ingesting your markdown docs.## Set-up
Start by creating a new Supabase Project: [database.new](https://database.new).
1. Clone this repo
2. Link the repo to your remote project: `supabase link --project-ref XXX`
3. Apply the database migrations: `supabase db push`
4. Set your OpenAI key as a secret: `supabase secrets set OPENAI_API_KEY=sk-xxx`
5. Deploy the Edge Functions: `supabase functions deploy --no-verify-jwt`
6. Expose `docs` schema via API in Supabase Dashboard [settings](https://app.supabase.com/project/_/settings/api) > `API Settings` > `Exposed schemas`
7. [Setup](https://github.com/supabase/supabase-vector-embeddings-github-action#use) `supabase-vector-embeddings` GitHub action in your Knowledge Base repo. You will see the embeddings populated in your database after the GitHub Action has run.## Usage
1. Find the URL for the `vector-search` Edge Function in the [Functions section](https://app.supabase.com/project/_/functions) of the Dashboard.
2. Inside your appliction, you can send the user queries to this endpoint to receive a streamed response from OpenAI.See cURL example
```bash
curl -i --location --request GET 'https://your-project-ref.functions.supabase.co/vector-search?query=What%27s+Supabase%3F'
```See EventSource example
```ts
const onSubmit = (e: Event) => {
e.preventDefault()
answer.value = ""
isLoading.value = trueconst query = new URLSearchParams({ query: inputRef.current!.value })
const projectUrl = `https://your-project-ref.functions.supabase.co`
const queryURL = `${projectURL}/${query}`
const eventSource = new EventSource(queryURL)eventSource.addEventListener("error", (err) => {
isLoading.value = false
console.error(err)
})
eventSource.addEventListener("message", (e: MessageEvent) => {
isLoading.value = falseif (e.data === "[DONE]") {
eventSource.close()
return
}const completionResponse: CreateCompletionResponse = JSON.parse(e.data)
const text = completionResponse.choices[0].textanswer.value += text
});isLoading.value = true
}
```## Showcase
- [docs.supabase.com](https://supabase.com/docs) - Use cmd+k to access.
## License
MIT