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