在 Python 中使用 DeepSeek
James Chapman
AI Curriculum Lead, DataCamp
response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V4-Pro",messages=[{"role": "user", "content": "Hi! I'm James and I'm a Curriculum Manager at DataCamp."}]) print(response.choices[0].message.content)
Hi James! It's great to meet you. As a **Curriculum Manager at DataCamp**, you must
play a key role in shaping the learning experience for data science and analytics
students. How can I assist you today?

temperature:控制从确定性到随机性的程度,0(高度确定)到 2(非常随机)response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V4-Pro", extra_body={"thinking": {"type": "disabled"}}, messages=[{"role": "user", "content": "Hi! I'm James and I'm a Curriculum Manager at DataCamp."}],temperature=2) print(response.choices[0].message.content)
Hi James! Welcome to DataCamp - it's great to connect with someone who works on
shaping learning experiences for data skills. What does your role typically involve
as a Curriculum Manager at **DataCamp?** Perhaps one-on95 kWielpulses.Z.blog.from...
prompt = "Generate a powerful tagline for a new electric vehicle
that highlights innovation and sustainability."
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role": "user", "content": prompt}]
)
print(response.choices[0].message.content)
**"Drive the Future - Zero Emissions, Infinite Innovation."**
该标语体现了前沿科技与环保意识的核心...
prompt = "Generate a powerful tagline for a new electric vehicle
that highlights innovation and sustainability. Return only the tagline
without formatting."
# Create a request to the chat model
# ...
"Drive the Future - Clean, Smart, Electric."
prompt = """Write a compelling e-commmerce product description for the UltraFit Smartwatch in paragraph form. Highlight its key features: 10-day battery life, 24/7 heart rate and sleep tracking, built-in GPS, water resistance up to 50 meters, and lightweight design. Use a persuasive and engaging tone to appeal to fitness enthusiasts and busy professionals. """response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V4-Pro", messages=[{"role": "user", "content": prompt}])
print(response.choices[0].message.content)
"UltraFit 智能手表是您的全能健康与健身伙伴。
24/7 心率与睡眠监测助您掌握健康状况,
内置 GPS 让跑步不偏航。
10 天续航,无需频繁充电。
轻量机身与 50 米防水,既适合训练也适合日常佩戴,是积极生活方式的理想之选。"
迭代!在提示中加入细节并重新运行请求
下个视频 → 向模型提供示例
在 Python 中使用 DeepSeek