開始使用免費開始

單次示例提示:這樣就夠了嗎?

如你所見,你的初始提示還有改進空間。試著加入一個範例 Love these! = 5,並在每則評論後面加上 =,看看是否能得到更一致的格式與更精確的數字。

本練習屬於課程

使用 Python 操作 DeepSeek

檢視課程

練習說明

  • 在提示開頭加入範例 Love these! = 5,並在提示中的每一則評論後面加上 =,以指示結果應該如何格式化。

動手互動練習

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

client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")

# Add the example to the prompt
prompt = """Classify sentiment as 1-5 (negative to positive). Return no explanations:
1. ____
2. Unbelievably good! ____
3. Shoes fell apart on the second use. ____
4. The shoes look nice, but they aren't very comfortable. ____
5. Can't wait to show them off! ____"""

response = client.chat.completions.create(model="deepseek-ai/DeepSeek-V4.1-Flash", messages=[{"role": "user", "content": prompt}], max_tokens=500)
print(response.choices[0].message.content)
編輯並執行程式碼