MulaiMulai sekarang secara gratis

Avoiding inconsistent responses

The team you were working with on the previous project is enthusiastic about the reply generator and asks you if more reviews can be processed. However, some reviews have been mixed up with other documents, and you're being asked not to return responses if the text doesn't contain a review, or relevant information. For example, the review you're considering now doesn't contain a product name, and so there should be no product name being returned.

In this exercise, the get_response() function, and messages and function_definition variables have been preloaded. The messages already contain the user's review, and function_definition contains the two functions: one asking to extract structured data, and one asking to generate a reply.

Latihan ini adalah bagian dari kursus

Developing AI Systems with the OpenAI API

Lihat Kursus

Petunjuk latihan

  • Modify the messages to ask the model not to assume any values for the responses.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

client = OpenAI(api_key="")

# Modify the messages
____

response = get_response(messages, function_definition)

print(response)
Edit dan Jalankan Kode