學習顧問聊天機器人
你正在開發一個可客製化的學習顧問聊天機器人,用來為使用者推薦教科書。這個聊天機器人的角色是接收學習者關於其背景、經驗與目標的提問,並據此推薦一條教科書學習路徑,包含入門與進階選項。你的工作是為這個教科書推薦聊天機器人撰寫一個角色扮演的 system_prompt,清楚強調它在與使用者互動時預期要完成的任務。
OpenAI 套件與 get_response() 函式都已為你預先載入。
本練習屬於課程
使用 OpenAI API 的提示工程
練習說明
- 定義一個角色扮演的
system_prompt,指示機器人扮演學習顧問,如前述能解讀學習者的提問,並提供相關的教科書推薦。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
client = OpenAI(api_key="")
# Craft the system_prompt using the role-playing approach
system_prompt = "____"
user_prompt = "Hello there! I'm a beginner with a marketing background, and I'm really interested in learning about Python, data analytics, and machine learning. Can you recommend some books?"
response = get_response(system_prompt, user_prompt)
print(response)