diff --git a/dsLightRag/ShiTi/T2_ImageToMd.py b/dsLightRag/ShiTi/T2_ImageToMd.py index afe6389a..2066762a 100644 --- a/dsLightRag/ShiTi/T2_ImageToMd.py +++ b/dsLightRag/ShiTi/T2_ImageToMd.py @@ -29,5 +29,5 @@ completion = client.chat.completions.create( ocr_text = completion.choices[0].message.content # 二、调用格式化函数处理内容 -format_exam_content(client=client, raw_text=ocr_text, output_path="../output/数学OCR整理后的结果.md") +format_exam_content(raw_text=ocr_text, output_path="../output/数学OCR整理后的结果.md") print("保存成功!") diff --git a/dsLightRag/ShiTi/T3_DocxToMd.py b/dsLightRag/ShiTi/T3_DocxToMd.py index cebddd88..8813d8b7 100644 --- a/dsLightRag/ShiTi/T3_DocxToMd.py +++ b/dsLightRag/ShiTi/T3_DocxToMd.py @@ -90,11 +90,7 @@ async def main(): f.write(content) # 新增:使用大模型整理内容 - format_exam_content( - client=llm_model_func(), - raw_text=content, - output_path=os.path.join(output_dir, "物理Docx整理后的结果.md") - ) + format_exam_content(raw_text=content, output_path=os.path.join(output_dir, "物理Docx整理后的结果.md")) logger.info(f"内容整理完成,保存至: {os.path.join(output_dir, '物理Docx整理后的结果.md')}") diff --git a/dsLightRag/Util/LightRagUtil.py b/dsLightRag/Util/LightRagUtil.py index 4771ae88..5a6de628 100644 --- a/dsLightRag/Util/LightRagUtil.py +++ b/dsLightRag/Util/LightRagUtil.py @@ -8,6 +8,8 @@ from lightrag import LightRAG from lightrag.kg.shared_storage import initialize_pipeline_status from lightrag.llm.openai import openai_complete_if_cache, openai_embed from lightrag.utils import EmbeddingFunc, logger, set_verbose_debug +from openai import OpenAI + from Config.Config import * @@ -181,7 +183,11 @@ def create_vision_model_func(llm_model_func): return vision_model_func -def format_exam_content(client, raw_text, output_path): +def format_exam_content(raw_text, output_path): + client = OpenAI( + api_key=LLM_API_KEY, + base_url=LLM_BASE_URL, + ) """ 将OCR识别的原始试卷内容格式化为标准试题格式 diff --git a/dsLightRag/Util/__pycache__/LightRagUtil.cpython-310.pyc b/dsLightRag/Util/__pycache__/LightRagUtil.cpython-310.pyc index e69b5941..5ee61c5f 100644 Binary files a/dsLightRag/Util/__pycache__/LightRagUtil.cpython-310.pyc and b/dsLightRag/Util/__pycache__/LightRagUtil.cpython-310.pyc differ diff --git a/dsLightRag/output/《动能定理》巩固练习/auto/《动能定理》巩固练习_origin.pdf b/dsLightRag/output/《动能定理》巩固练习/auto/《动能定理》巩固练习_origin.pdf index ba97c1f4..d4c646a7 100644 Binary files a/dsLightRag/output/《动能定理》巩固练习/auto/《动能定理》巩固练习_origin.pdf and b/dsLightRag/output/《动能定理》巩固练习/auto/《动能定理》巩固练习_origin.pdf differ