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.
24 lines
697 B
24 lines
697 B
from openai import OpenAI
|
|
|
|
# 阿里云中用来调用 deepseek r1 的密钥
|
|
MODEL_API_KEY = "sk-01d13a39e09844038322108ecdbd1bbc"
|
|
MODEL_NAME = "deepseek-v3"
|
|
|
|
# 初始化 OpenAI 客户端
|
|
client = OpenAI(
|
|
api_key=MODEL_API_KEY,
|
|
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
)
|
|
|
|
# 调用语言模型
|
|
completion = client.chat.completions.create(
|
|
model=MODEL_NAME,
|
|
messages=[
|
|
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
|
{'role': 'user', 'content': '你是谁?'}
|
|
],
|
|
)
|
|
|
|
# 提取并打印文本内容
|
|
response_content = completion.choices[0].message.content
|
|
print("返回的文本内容:", response_content) |