parent
6024b249f2
commit
ffdb664760
@ -0,0 +1,24 @@
|
||||
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)
|
Loading…
Reference in new issue