|
|
@ -1,16 +1,11 @@
|
|
|
|
import os
|
|
|
|
|
|
|
|
from openai import OpenAI
|
|
|
|
from openai import OpenAI
|
|
|
|
|
|
|
|
|
|
|
|
client = OpenAI(
|
|
|
|
client = OpenAI(
|
|
|
|
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
|
|
|
|
|
|
|
|
api_key='sk-f6da0c787eff4b0389e4ad03a35a911f',
|
|
|
|
api_key='sk-f6da0c787eff4b0389e4ad03a35a911f',
|
|
|
|
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
|
|
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
prompt = "请提取图片中的试题"
|
|
|
|
prompt = "请提取图片中的试题"
|
|
|
|
#prompt += "1、需要Latex公式输出的,注意加上 $$ 或 $ 进行包含。"
|
|
|
|
|
|
|
|
#prompt += "2、以中文数字开头的行,请忽律掉此行,比如 一、单项选择题 二、填空题 ..."
|
|
|
|
|
|
|
|
#prompt += "3、输出格式: 【题型】xxx 【题目内容】 xxx 【答案】 xxxx 【解析】 xxxx。"
|
|
|
|
|
|
|
|
completion = client.chat.completions.create(
|
|
|
|
completion = client.chat.completions.create(
|
|
|
|
model="qwen-vl-ocr-latest",
|
|
|
|
model="qwen-vl-ocr-latest",
|
|
|
|
messages=[
|
|
|
|
messages=[
|
|
|
@ -36,7 +31,7 @@ completion = client.chat.completions.create(
|
|
|
|
print(completion.choices[0].message.content)
|
|
|
|
print(completion.choices[0].message.content)
|
|
|
|
|
|
|
|
|
|
|
|
# 将返回的内容保存到 2、识别出结果.md 中
|
|
|
|
# 将返回的内容保存到 2、识别出结果.md 中
|
|
|
|
with open('2、识别出结果.md', 'w', encoding='utf-8') as f:
|
|
|
|
with open('Res/2、识别出结果.md', 'w', encoding='utf-8') as f:
|
|
|
|
f.write(completion.choices[0].message.content)
|
|
|
|
f.write(completion.choices[0].message.content)
|
|
|
|
|
|
|
|
|
|
|
|
print("保存成功!")
|
|
|
|
print("保存成功!")
|
|
|
|