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.

27 lines
1.1 KiB

2 weeks ago
import os
from openai import OpenAI
try:
client = OpenAI(
# 若没有配置环境变量请用百炼API Key将下行替换为api_key="sk-xxx",
api_key='sk-f6da0c787eff4b0389e4ad03a35a911f',
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
2 weeks ago
# 读取md文件内容
with open("2、识别出结果.md", "r", encoding="utf-8") as f:
text = f.read()
2 weeks ago
completion = client.chat.completions.create(
# 模型列表https://help.aliyun.com/zh/model-studio/getting-started/models
model="qwen-plus",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
2 weeks ago
{"role": "user",
"content": "我将提供一份markdown格式的试卷帮我整理出每道题的题目序号内容答案解析并最终输出一共整理了多少道题。内容如下" + text},
2 weeks ago
],
)
print(completion.choices[0].message.content)
except Exception as e:
print(f"错误信息:{e}")
2 weeks ago
print("请参考文档https://help.aliyun.com/zh/model-studio/developer-reference/error-code")