恭喜您!

在 Python 中使用 DeepSeek

James Chapman

AI Curriculum Lead, DataCamp

第 1 章

 

  • 在聊天与推理模式下向 DeepSeek 发送请求

高层次推理流程:思考、执行与更新知识。

DeepSeek 标志。

client = OpenAI(api_key="<TogetherAI API Key>")

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4.1-Flash",
    messages=[{"role": "user", "content": "..."}]
)
print(response.choices[0].message.content)
在 Python 中使用 DeepSeek

第 2 章

response = client.chat.completions.create(
  model="deepseek-ai/DeepSeek-V4.1-Flash",
  messages=[{"role": "user", "content": "..."}],
  max_tokens=20,
  temperature=0.5
)
  • 问答
  • 文本变换
  • 内容生成
  • 分类,例如情感分析
  • 代码调试
  • max_tokenstemperature

不同 DeepSeek 模型的应用场景。

在 Python 中使用 DeepSeek

第 3 章

 

  • "system"

    • 引导模型输出
    • 增加防护规则
  • "assistant"

    • 结构化少样本提示
    • 构建对话历史

聊天交互的三种角色:system、user、assistant。

在 Python 中使用 DeepSeek

接下来做什么?

在 Python 中使用 DeepSeek

让我们一起练习吧!

在 Python 中使用 DeepSeek

Preparing Video For Download...