Response translation
You now have a tailored response from the chatbot that passed moderation. Your next task is to translate that response into the original language of the customer request.
The model's reply and the detected country code from the previous exercises are available as chatbot_reply and country_code.
Latihan ini adalah bagian dari kursus
Multi-Modal Systems with the OpenAI API
Petunjuk latihan
- Use the
gpt-4o-minimodel to translatechatbot_replyinto the language specified bycountry_code. - Extract the translated text from
response.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
client = OpenAI(api_key="")
# Translate chatbot reply
response = ____
# Extract translated text
translated_reply = ____
print(translated_reply)