You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
603 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 安装 OpenAI SDK
# pip install openai
from openai import OpenAI
from Config import Config
# 创建 API 客户端
client = OpenAI(api_key=Config.DEEPSEEK_API_KEY, base_url=Config.DEEPSEEK_URL)
# 调用 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 可启用流式输出
)
# 输出响应内容
print(response.choices[0].message.content)