开始使用免费开始使用

少样本提示:把示例都用上!

压轴环节!请在提示中再添加最后一个示例 Comfortable, but not very pretty = 2,看看是否还能进一步提升效果。

本练习是课程的一部分

在 Python 中使用 DeepSeek

查看课程

练习说明

  • 将示例 Comfortable, but not very pretty = 2 添加到提示中,并重新运行请求。

交互式实操练习

通过完成这段示例代码来试试这个练习。

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

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

response = client.chat.completions.create(model="deepseek-ai/DeepSeek-V4-Pro", messages=[{"role": "user", "content": prompt}], max_tokens=500)
print(response.choices[0].message.content)
编辑并运行代码