Skip to content

Instantly share code, notes, and snippets.

@dmagda
Created January 9, 2024 16:18
Show Gist options
  • Save dmagda/cf0abc86b27eb0169c816bdefe24815b to your computer and use it in GitHub Desktop.
Save dmagda/cf0abc86b27eb0169c816bdefe24815b to your computer and use it in GitHub Desktop.
Movies Recommendations Snippet

"Movies Recommendations"

client.sql(
    "SELECT id, title, overview, vote_average " +
    "FROM movie WHERE vote_average >= 7 " +
    "AND genres @> \'[{\"name\": \"Science Fiction\"}]\'" +
    "AND 1 - (overview_vector <=> :prompt_vector::vector) >= 0.7 " +
    "ORDER BY overview_vector <=> :prompt_vector::vector LIMIT 3")
    .param("prompt_vector", promptEmbedding.toString())
    .query(Movie.class).list();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment