main
HuangHai 1 month ago
parent 308089e65c
commit 8492a38f1c

@ -6,15 +6,18 @@ from Config import Config
# 创建 API 客户端
client = OpenAI(api_key=Config.DEEPSEEK_API_KEY, base_url=Config.DEEPSEEK_URL)
# 调用 deepseek-chat 模型
# 调用 deepseek-chat 模型(流式模式)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "什么是CNN神经网络?"},
],
stream=False # 设置为 True 可启用流式输出
stream=True # 启用流式输出
)
# 输出响应内容
# 流式输出响应内容
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
print(response.choices[0].message.content)

Loading…
Cancel
Save