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
1007 B

1 month ago
from openai import OpenAI
1 month ago
from Util.LightRagUtil import format_exam_content
1 month ago
from Config.Config import *
1 month ago
1 month ago
# 一、调用OCR整理出试题
1 month ago
client = OpenAI(
1 month ago
api_key=LLM_API_KEY,
base_url=LLM_BASE_URL,
1 month ago
)
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
},
1 month ago
{"type": "text", "text": prompt},
1 month ago
]
}
])
1 month ago
ocr_text = completion.choices[0].message.content
1 month ago
1 month ago
# 二、调用格式化函数处理内容
1 month ago
format_exam_content(raw_text=ocr_text, output_path="../output/数学OCR整理后的结果.md")
1 month ago
print("保存成功!")