DEV Community

Cover image for FilmGuru: Your AI-Powered Movie Companion šŸŽ¬
Chijioke Osadebe
Chijioke Osadebe

Posted on

FilmGuru: Your AI-Powered Movie Companion šŸŽ¬

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

What I Built | FilmGuru

FilmGuru is an AI movie recommendation engine designed to help you discover the perfect film from a curated database of over 8,000 IMDb movies. Whether youā€™re in the mood for another mind-bender after watching Inception or just want to try something similar to the last masterpiece you enjoyed, FilmGuruā€™s got you covered!

Why FilmGuru?

Ever found yourself scrolling endlessly, unable to decide on your next movie? FilmGuru solves that by understanding what you enjoyed in your last watch and recommending something with a similar vibe. Think of it as your personal movie guru! With FilmGuru, a recommendation isnā€™t just a listā€”itā€™s a hand-picked suggestion designed to turn "meh" into "2 hours of pure bliss."

Image description

Hereā€™s a sneak peek at a recommendation! With FilmGuru, finding your next favorite film is as easy as pressing play.

Demo

You can try the app out here
Thank you for exploring FilmGuru!

Tools Used

NextJS
pgai
pgvector
pgvectorizer

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

What I Built | FilmGuru

FilmGuru is an AI movie recommendation engine designed to help you discover the perfect film from a curated database of over 8,000 IMDb movies. Whether youā€™re in the mood for another mind-bender after watching Inception or just want to try something similar to the last masterpiece you enjoyed, FilmGuruā€™s got you covered!

Why FilmGuru?

Ever found yourself scrolling endlessly, unable to decide on your next movie? FilmGuru solves that by understanding what you enjoyed in your last watch and recommending something with a similar vibe. Think of it as your personal movie guru! With FilmGuru, a recommendation isnā€™t just a listā€”itā€™s a hand-picked suggestion designed to turn "meh" into "2 hours of pure bliss."

Image description

Hereā€™s a sneak peek at a recommendation! With FilmGuru, finding your next favorite film is as easyā€¦

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

What I Built | FilmGuru

FilmGuru is an AI movie recommendation engine designed to help you discover the perfect film from a curated database of over 8,000 IMDb movies. Whether youā€™re in the mood for another mind-bender after watching Inception or just want to try something similar to the last masterpiece you enjoyed, FilmGuruā€™s got you covered!

Why FilmGuru?

Ever found yourself scrolling endlessly, unable to decide on your next movie? FilmGuru solves that by understanding what you enjoyed in your last watch and recommending something with a similar vibe. Think of it as your personal movie guru! With FilmGuru, a recommendation isnā€™t just a listā€”itā€™s a hand-picked suggestion designed to turn "meh" into "2 hours of pure bliss."

Image description

Hereā€™s a sneak peek at a recommendation! With FilmGuru, finding your next favorite film is as easyā€¦

Image description

FilmGuruā€™s journey begins with my movie database, a CSV file sourced from Kaggle, containing 8,000 movie records with details like descriptions, year, and other metadata. Hereā€™s how it all comes together:

I started by uploading the CSV to Timescale as a new service, which took just 2 minutes to complete.
Using the SQL editor, I added a primary key column to the tableā€”this is crucial for utilizing Timescaleā€™s pgvectorizer functionality.
I then used the vectorizer with OpenAIā€™s embedding model (small) to generate embeddings instantly across the entire database, creating a vector representation for each movie entry to allow FilmGuru to find the best matches based on your preferences.

The original CSV file included fields for title, description, year, duration, rating, and stars, among others. I kept only these essential fields, discarding the rest. Since the movie descriptions were quite lengthy, I divided them into chunks, adding key contextual fields to each chunk to retain as much relevant information as possible.

async function Vectorizer() {
  try {
    await pool.query(
      `
      SELECT ai.create_vectorizer(
      'public.imdb_numbered_votes'::regclass,
      embedding=>ai.embedding_openai('text-embedding-3-small', 1536, api_key_name=>'OPENAI_API_KEY'),
      chunking=>ai.chunking_recursive_character_text_splitter('description'),
      formatting=>ai.formatting_python_template('title: $title description: $chunk, year: $year, duration: $duration, rating: $rating, stars: $stars')
      );
      `,
    );
    return { status: "success" };
  } catch (error) {
    console.log(error);
    return { status: "failed" };
  }
}
Enter fullscreen mode Exit fullscreen mode

Behind the Scenes of Your Recommendation Journey

When you enter a prompt (like "I want something like Inception"), itā€™s sent to the backend server.
The server uses pg AI to create a unique embedding for your query with the help of OpenAI's text-embedding-3-small, transforming it into a vector.
FilmGuru then uses pgvector to search the database for movies with similar embeddings, delivering the closest match as your next recommendation.

Itā€™s seamless, fast, and incredibly fun!

Final Thoughts

The project came up smooth. I only had one dependency in my back end. That was the pg library for postgres. Kinda cool that I could build the entire backend just with one library.

Iā€™m planning to add an agent that fetches images for each movie, making recommendations even more visually engaging. Stay tuned!

All the Extensions

Top comments (0)