Dan Ryland. Is. Supabase Vector Database.
We’ve all seen that Office episode.
Dwight can’t contain the excitment of his promotion.
He leaps onto the table, punches into the air and shouts:
“Dwight Schrute. Is. Manager.”
The office swiftly follows with applause.
Well, what if…
**Jumps onto desk**
Dan Ryland. Is. Supabase Vector Database!?
I’ve been a massive fan of Supabase for a while.
The community, the auth, the databases, storage, image transformations, edge functions, launch weeks, the hackathons and now?
Those sweet vector fields.
I entered my first ever hackathon for their Launch Week 7 with my Groove AI app.
Groove AI generates drum patterns for you to play, customise and even download as MIDI.
To my absolute surprise, I won silver!
I couldn’t believe it.
But silver wasn’t enough.
I had to try better.
I wanted that sweet gold.
Launch week 8 comes.
This time I’ve come for gold.
Blending the visual style of Rick and Morty with the well known talent competition XFactor, I designed and built Supafactor.
Supafactor is now the way to judge hackathon entries.
Through four criteria: creativity, functionality, Supabase-ness and fun, our Supafactor judge (Simon Cowell) gives realtime feedback on the README of your hackathon entry.
The result?
Beautiful gold.
I did it.
I was so happy I did many an Anchorman celebratory jump.
Fast forward to today and I’m pushing Supabase’s features further.
Let’s set the scene.
I co-host the podcast, Don’t be a Doorstop
Why the name?
Yes, a hammer can be a good doorstop, but its real purpose is to hammer nails.
So Hammer, don’t be a doorstop. Let’s go find you some nails.
Don’t be a Doorstop is about purpose, mindset and entrepreneurship.
Let’s jump to AI characters, AI therapists and AI girlfriends.
Inspired by these AI characters, I thought, what if I could create an AI version of myself as a coach?
Enter our Coach AI, or it’s cute character name, ‘Hammer’
Using the podcast episodes, I transcribed my half of the audio with Open AI’s Whisper.
I broke those text transcriptions into smaller, overlapping chunks.
After some reading, I decided to ‘chunk’ the transcripts into 6 sentences each with 2 sentences as overlap to keep some context continuation.
I then used Open AI’s text-embedding-ada-002
model to create embeddings for each of the chunks.
After some clean up, this resulted in 1,040 rows in my Supabase database, each with its own vector value.
Now comes the interesting part.
I built a simple Quasar app to take a question as input, converted the question to an vector embed then query the database using the vector value via a custom Postgres function.
CREATE OR REPLACE FUNCTION match_snippets (
query_embedding vector(512),
match_threshold float,
match_count int
)
RETURNS TABLE (
id bigint,
content text,
similarity float
)
LANGUAGE SQL STABLE
AS $$
SELECT
snippets.id,
snippets.content,
1 - (snippets.embedding <=> query_embedding) AS similarity
FROM snippets
WHERE 1 - (snippets.embedding <=> query_embedding) > match_threshold
ORDER BY similarity DESC
LIMIT match_count;
$$;
This returns 20 relevant snippets from the podcast that can now be used as context to answer the original question.
With a good system prompt
I fed it: the task I wanted it to perform, the original question and the returned snippets for its context.
This then returns a beautiful answer driven from pod content.
It’s beautiful.
I’ve codified myself into a vector database and made myself into a cute hammer.
Now, I’d like to take this further:
Telegram bot and audio responses - that could actually sound like me.
I’m now working on shifting this into a Supabase Edge Function and integrating it with grammY, an open source Telegram bot framework.
Supabase has a great walkthrough on how to get you going.
Here’s proof Hammer lives:
If you’re interested in following my progress follow me on X
And if you haven’t used Supabase yet, I highly recomend you try Supabase today.
Until next time, keep hammering those nails.