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.

34 lines
1.1 KiB

2 weeks ago
from openai import OpenAI
2 weeks ago
from Util.LightRagUtil import format_exam_content
2 weeks ago
2 weeks ago
# 一、调用OCR整理出试题
2 weeks ago
client = OpenAI(
api_key='sk-f6da0c787eff4b0389e4ad03a35a911f',
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
prompt = "请提取图片中的试题"
completion = client.chat.completions.create(
model="qwen-vl-ocr-latest",
messages=[
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": "https://ylt.oss-cn-hangzhou.aliyuncs.com/HuangHai/Test/Source.jpg",
"min_pixels": 28 * 28 * 4,
"max_pixels": 28 * 28 * 8192
},
2 weeks ago
{"type": "text", "text": prompt},
2 weeks ago
]
}
])
2 weeks ago
ocr_text = completion.choices[0].message.content
2 weeks ago
2 weeks ago
# 二、调用格式化函数处理内容
2 weeks ago
formatted_content = format_exam_content(client=client, raw_text=ocr_text,
output_path="../output/数学OCR整理后的结果.md")
2 weeks ago
print("保存成功!")