mirror of
https://github.com/supabase/supabase.git
synced 2026-07-11 01:23:19 -04:00
d5fde192d5
- extends/supersedes: #46665 - towards COM-269 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Standardized Edge Function entrypoints across examples to a consistent `export default` shape, with runtime-provided admin access for storage/database operations. * Updated public endpoint handling to use appropriate auth modes. * **Bug Fixes** * Improved error handling to return structured JSON responses with correct HTTP status codes for invalid requests and failures. * Harmonized local invocation examples to use the right header format. * **Chores** * Updated example `verify_jwt` settings to disable JWT verification for public/demo endpoints. * **Documentation** * Fixed README typo and refreshed invocation curl examples. * **Tests** * None. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Tomas Pozo <tomaspozogarzon@gmail.com>
AI Inference in Supabase Edge Functions
Since Supabase Edge Runtime v1.36.0 you can run the gte-small model natively within Supabase Edge Functions without any external dependencies! This allows you to easily generate text embeddings without calling any external APIs!
Semantic Search with pgvector and Supabase Edge Functions
This demo consists of three parts:
- A
generate-embeddingdatabase webhook edge function which generates embeddings when a content row is added (or updated) in thepublic.embeddingstable. - A
query_embeddingsPostgres function which allows us to perform similarity search from an edge function via Remote Procedure Call (RPC). - A
searchedge function which generates the embedding for the search term, performs the similarity search via RPC function call, and returns the result.
Deploy
- Link your project:
supabase link - Deploy Edge Functions:
supabase functions deploy - Update project config to enable webhooks:
supabase config push - Navigate to the database-webhook migration file and insert your
generate-embeddingfunction details. - Push up the database schema
supabase db push
Run
Run a search via curl POST request:
curl -i --location --request POST 'https://<PROJECT-REF>.supabase.co/functions/v1/search' \
--header 'apikey: <SUPABASE_SECRET_KEY>' \
--header 'Content-Type: application/json' \
--data '{"search":"vehicles"}'