開始使用免費開始

更多 assistant 訊息!

延伸你先前的訊息,加入更多範例,並分別存成 example1response1example2response2example3response3

來看看能不能讓模型依照預期的格式輸出資訊!

本練習屬於課程

使用 Python 操作 DeepSeek

檢視課程

練習說明

  • 延伸你先前的訊息,加入其他國家的額外範例,並分別存成 example1response1example2response2example3response3

動手互動練習

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

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

response = client.chat.completions.create(
   model="deepseek-ai/DeepSeek-V4.1-Flash",
   # Add in the extra examples and responses
   messages=[
       {"role": "system", "content": "You are a helpful Geography tutor that generates concise, one-sentence summaries for different countries."},
       {"role": "user", "content": "Give me a quick summary of Portugal."},
       {"role": "assistant", "content": "Portugal is a country in Europe that borders Spain. The capital city is Lisboa."},
       {"role": "user", "content": ____},
       {"role": "assistant", "content": ____},
       {"role": "user", "content": ____},
       {"role": "assistant", "content": ____},
       {"role": "user", "content": ____},
       {"role": "assistant", "content": ____},
       {"role": "user", "content": "Give me a quick summary of Greece."}
   ]
)

print(response.choices[0].message.content)
編輯並執行程式碼