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