MulaiMulai sekarang secara gratis

Querying the Netflix collection

Now that you've created and populated the netflix_titles collection, it's time to query it!

As a first trial, you'll use it to provide recommendations for films and TV shows about dogs to one of your colleagues who loves dogs!

The netflix_titles collection is still available to use, and OpenAIEmbeddingFunction() has been imported.

Latihan ini adalah bagian dari kursus

Introduction to Embeddings with the OpenAI API

Lihat Kursus

Petunjuk latihan

  • Retrieve the netflix_titles collection, specifying the OpenAI embedding function so the query is embedded using the same function as the documents.
  • Query the collection for "films about dogs" and return three results.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Retrieve the netflix_titles collection
collection = ____(
  name="____",
  embedding_function=____(model_name="text-embedding-3-small", api_key="")
)

# Query the collection for "films about dogs"
result = ____

print(result)
Edit dan Jalankan Kode