diff --git a/dsRagAnything/Test/Ocr/1、源图.jpg b/dsRagAnything/Test/Ocr/Res/1、源图.jpg similarity index 100% rename from dsRagAnything/Test/Ocr/1、源图.jpg rename to dsRagAnything/Test/Ocr/Res/1、源图.jpg diff --git a/dsRagAnything/Test/Ocr/2、识别出结果.md b/dsRagAnything/Test/Ocr/Res/2、识别出结果.md similarity index 100% rename from dsRagAnything/Test/Ocr/2、识别出结果.md rename to dsRagAnything/Test/Ocr/Res/2、识别出结果.md diff --git a/dsRagAnything/Test/Ocr/3、整理后的结果.md b/dsRagAnything/Test/Ocr/Res/3、整理后的结果.md similarity index 100% rename from dsRagAnything/Test/Ocr/3、整理后的结果.md rename to dsRagAnything/Test/Ocr/Res/3、整理后的结果.md diff --git a/dsRagAnything/Test/Ocr/T1_QWenOcr.py b/dsRagAnything/Test/Ocr/T1_QWenOcr.py index 17a55ded..e1ab2e1b 100644 --- a/dsRagAnything/Test/Ocr/T1_QWenOcr.py +++ b/dsRagAnything/Test/Ocr/T1_QWenOcr.py @@ -1,16 +1,11 @@ -import os from openai import OpenAI client = OpenAI( - # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx", api_key='sk-f6da0c787eff4b0389e4ad03a35a911f', base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", ) prompt = "请提取图片中的试题" -#prompt += "1、需要Latex公式输出的,注意加上 $$ 或 $ 进行包含。" -#prompt += "2、以中文数字开头的行,请忽律掉此行,比如 一、单项选择题 二、填空题 ..." -#prompt += "3、输出格式: 【题型】xxx 【题目内容】 xxx 【答案】 xxxx 【解析】 xxxx。" completion = client.chat.completions.create( model="qwen-vl-ocr-latest", messages=[ @@ -36,7 +31,7 @@ completion = client.chat.completions.create( print(completion.choices[0].message.content) # 将返回的内容保存到 2、识别出结果.md 中 -with open('2、识别出结果.md', 'w', encoding='utf-8') as f: +with open('Res/2、识别出结果.md', 'w', encoding='utf-8') as f: f.write(completion.choices[0].message.content) print("保存成功!") diff --git a/dsRagAnything/Test/Ocr/T2_Translation.py b/dsRagAnything/Test/Ocr/T2_Translation.py index c4eb5cf6..e6eac1da 100644 --- a/dsRagAnything/Test/Ocr/T2_Translation.py +++ b/dsRagAnything/Test/Ocr/T2_Translation.py @@ -1,4 +1,3 @@ -import os from openai import OpenAI try: @@ -8,7 +7,7 @@ try: base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", ) # 读取md文件内容 - with open("2、识别出结果.md", "r", encoding="utf-8") as f: + with open("Res/2、识别出结果.md", "r", encoding="utf-8") as f: text = f.read() prompt = """ @@ -38,7 +37,7 @@ try: ) print(completion.choices[0].message.content) # 将上面的返回内容写入到文件 3、整理后的结果.md 中 - with open("3、整理后的结果.md", "w", encoding="utf-8") as f: + with open("Res/3、整理后的结果.md", "w", encoding="utf-8") as f: f.write(completion.choices[0].message.content) print("保存成功!") except Exception as e: