逐步解釋程式碼
你是顧問公司的財務分析師,負責分析投資組合並向客戶提供洞見。檢視一組財務資料檔時,你發現一個與投資組合分析相關的 Python function,但不確定它的確切用途。你決定使用 chain-of-thought 提示,讓語言模型逐步拆解並解讀它。
OpenAI 套件、function 字串,以及 get_response() 函式都已為你預先載入。
本練習屬於課程
使用 OpenAI API 的提示工程
練習說明
- 撰寫一個 chain-of-thought 提示,要求模型解釋所提供的
function。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
client = OpenAI(api_key="")
# Craft a chain-of-thought prompt that asks the model to explain what the function does
prompt = ____
response = get_response(prompt)
print(response)