恭喜!

使用 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...