Supabase hired me to build ClippyGPT – their next generation doc search. We can ask our old friend Clippy anything you want about Supabase, and it will answer it using natural language. Powered by OpenAI + prompt engineering.
In this video I will be showing you exactly how I did this, and how you can do the same in your projects. We’ll be covering:
– Prompt engineering and best practices
– Working with a custom knowledge base via context injection + OpenAI embeddings
– How to store embeddings in Postgres using pgvector
Supabase blog post:
https://supabase.com/blog/chatgpt-supabase-docs
pgvector extension:
https://github.com/pgvector/pgvector
Generate embeddings implementation:
https://github.com/supabase/supabase/blob/54d39d4958575e5b58aa1d5d2a02db863ab4673c/apps/docs/scripts/generate-embeddings.ts
Clippy edge function implementation:
https://github.com/supabase/supabase/blob/54d39d4958575e5b58aa1d5d2a02db863ab4673c/supabase/functions/clippy-search/index.ts
Clippy frontend implementation:
https://github.com/supabase/supabase/blob/54d39d4958575e5b58aa1d5d2a02db863ab4673c/packages/ui/src/components/Command/AiCommand.tsx
Prompt engineering:
https://prmpts.ai/blog/what-is-prompt-engineering
00:00 Why?
01:40 Let’s get started
03:15 Custom knowledge base
04:49 Context injection
06:13 Pre-process MDX files
13:40 Embeddings
15:40 Storing in Postgres + pgvector
22:21 API endpoint (edge function)
23:44 Calculating similarity in pgvector
27:55 Prompt engineering
33:15 Prompt best practices
38:37 Demo time!
41:32 Thanks for watching!