開始使用免費開始

判斷客戶使用的語言

你已經有這通客戶來電的逐字稿,接下來需要推斷他所使用的語言,之後才能把回覆翻譯成客戶的母語。你會使用 OpenAI 的聊天模型來辨識語言。

模型的輸出應標準化為國碼;例如英文用 "en"、法文用 "fr",以此類推。

你在上一個練習建立的逐字稿已儲存在 transcript

本練習屬於課程

使用 OpenAI API 的多模態系統

檢視課程

練習說明

  • 提示 gpt-4o-mini 參考逐字稿並回傳所使用語言的國碼,例如英文為 "en"、法文為 "fr"
  • response 中擷取國碼。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

client = OpenAI(api_key="")

# Complete a request identify the country code from the transcript
response = ____

# Extract the country code from the response
country_code = ____
print(country_code)
編輯並執行程式碼