DEV Community

Cover image for Built with Timescale: Cook This App
Trang Le
Trang Le

Posted on

Built with Timescale: Cook This App

This is a submission for the Open Source AI Challenge with pgai and Ollama

What I Built

If you regularly cook through online recipes, you know the deal: There are more recipes than we can cook in our lifetimes, but there is no efficient way to search for recipes.

Traditionally, you have to use the exact words to search recipes. If your intention is broader, like "seafood recipes", "mediterranean salad", "asian desserts", you're out of luck. You are very likely to miss out many awesome recipes because they don't include the right words.

For example, many salmon recipes don't contain the word "fish" because that's self-explanatory. So you may not get salmon recipes if you use the keyword "seafood recipes".

And sometimes you want to fine-tune your search. For example, you want recipes with the least amount of eggs, or recipes with the most amount of proteins for sustenance. Traditional keyword-based search can't do that.

That's why I built Cook This App, an AI-powered app that allows you to do two things far more powerful than traditional keyword search:

  • Search for recipes based on your intention. This feature requires more than just vector search and it is made possible via RAG.
  • Ask some analytical questions regarding the recipes. This feature is

Demo

Link to the app
Client repo
Server repo

The initial state of the app:

App's initial state

Try either of these two things, or try both:

#1: Search for recipes without having to use the exact words.

Example of queries you may try: "Italian desserts", "Asian dishes", "seafood dishes".

Here is what Cook This App sent back to me when I searched for "desserts":

State of the app after doing recipe search

Watch the recipe search feature in action here

#2: Probe Cook This App with questions that are not easily searchable

Example: "What is dish that uses the most meat?".

The answer I got:

State of the app after asking

Watch the recipe analysis in action here

Your results may change as I add more recipes to the database. Have fun!

Tools Used

pgai vectorizer for mapping words in the recipe database to numbers. This is the foundation for implementing similarity search and RAG.
pgai for doing all the groundwork in half the time:

  • storing embeddings in pgvector data types
  • getting OpenAI similarity search and chat completion right inside PostgreSQL database

pgvector for running similarity search on recipes

Final Thoughts

Without a machine learning background, I've never thought that one day I would be able to develop an AI application. But pgai makes it possible. It empowers developers to travel fast from ideas to production-ready AI applications.

I'm a frontend folk who still have to google every time I want to run an SQL query. So Timescale is such a lifesaver for hosting a PostgreSQL database so that I can focus on bringing better digital experience to users.

Top comments (1)

Collapse
 
schemetastic profile image
Schemetastic (Rodrigo)

Hey! Very interesting entry! ๐Ÿ‘๐Ÿฝ๐Ÿ‘๐Ÿฝ