MulaiMulai sekarang secara gratis

Nesting Pydantic Classes

Your movie recommendation system is working well, but there is room for improvements. In particular, with your recommendations, you want to add other, similar movies for the user to browse. These similar movies require a separate class (SimilarMovie) so that they can be listed within a new DetailedMovieRecommendation class.

Latihan ini adalah bagian dari kursus

Working with the OpenAI Responses API

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Define the SimilarMovie class
class ____(____):
    ____: str = Field(description="Title of a similar movie")
    ____: str = Field(description="Why this movie is similar")
Edit dan Jalankan Kode