diff --git a/dsLightRag/Config/Config.py b/dsLightRag/Config/Config.py index 6bcc5fb5..8b5e93cc 100644 --- a/dsLightRag/Config/Config.py +++ b/dsLightRag/Config/Config.py @@ -15,6 +15,10 @@ EMBED_BASE_URL = "https://api.siliconflow.cn/v1" EMBED_DIM = 1024 EMBED_MAX_TOKEN_SIZE = 8192 +# 视觉模型 +VISION_API_KEY = "sk-pbqibyjwhrgmnlsmdygplahextfaclgnedetybccknxojlyl" +VISION_BASE_URL = "https://api.siliconflow.cn/v1/chat/completions" +VISION_MODEL_NAME = "GLM-4.1V-9B-Thinking" NEO4J_URI = "bolt://localhost:7687" NEO4J_USERNAME = "neo4j" diff --git a/dsLightRag/Config/__pycache__/Config.cpython-310.pyc b/dsLightRag/Config/__pycache__/Config.cpython-310.pyc index 02dba342..7b37be29 100644 Binary files a/dsLightRag/Config/__pycache__/Config.cpython-310.pyc and b/dsLightRag/Config/__pycache__/Config.cpython-310.pyc differ diff --git a/dsLightRag/Config/__pycache__/__init__.cpython-310.pyc b/dsLightRag/Config/__pycache__/__init__.cpython-310.pyc index a118d2da..ce15d799 100644 Binary files a/dsLightRag/Config/__pycache__/__init__.cpython-310.pyc and b/dsLightRag/Config/__pycache__/__init__.cpython-310.pyc differ diff --git a/dsLightRag/ShiTi/Res/整理后的结果.md b/dsLightRag/ShiTi/Res/整理后的结果.md index b6ec30ec..b84bda6b 100644 --- a/dsLightRag/ShiTi/Res/整理后的结果.md +++ b/dsLightRag/ShiTi/Res/整理后的结果.md @@ -1,61 +1,49 @@ -### 题目1 -**题目序号**: 1 -**题目内容**: 已知集合 $A=\left\{x \mid -5 < x^{3} < 5\right\}, B=\left\{-3,-1,0,2,3\right\}$,则 $A \cap B=$ -**选项**: -A. $\{-1,0\}$ -B. $\{2,3\}$ -C. $\{-3,-1,0\}$ -D. $\{-1,0,2\}$ -**答案**: A -**解析**: $A \cap B=\{-1,0\}$,选 A。 - ---- - -### 题目2 -**题目序号**: 2 -**题目内容**: 若 $\frac{2}{z-1}=1+i$,则 $z=$ -**选项**: -A. $-1-i$ -B. $-1+i$ -C. $1-i$ -D. $1+i$ -**答案**: C - ---- - -### 题目3 -**题目序号**: 3 -**题目内容**: 已知向量 $\vec{a}=(0,1)$,$\vec{b}=(2,x)$,若 $\vec{b} \perp (\vec{b}-4\vec{a})$,则 $x=$ -**选项**: -A. $-2$ -B. $-1$ -C. $1$ -D. $2$ -**答案**: D -**解析**: $\vec{b}-4\vec{a}=(2,x-4)$,$\vec{b} \perp (\vec{b}-4\vec{a})$,$\therefore \vec{b}(\vec{b}-4\vec{a})=0$,$\therefore 4+x(x-4)=0$,$\therefore x=2$,选 D。 - ---- - -### 题目4 -**题目序号**: 4 -**题目内容**: 已知 $\cos(\alpha+\beta)=m$,$\tan \alpha \tan \beta=2$,则 $\cos(\alpha-\beta)=$ -**选项**: -A. $-3m$ -B. $-\frac{m}{3}$ -C. $\frac{m}{3}$ -D. $3m$ -**答案**: A -**解析**: $\left\{\begin{array}{l}\cos \alpha \cos \beta-\sin \alpha \sin \beta=m \\\frac{\sin \alpha \sin \beta}{\cos \alpha \cos \beta}=2\end{array}\right.$,$\therefore \left\{\begin{array}{l}\sin \alpha \sin \beta=-2m \\\cos \alpha \cos \beta=-m\end{array}\right.$ $\cos(\alpha-\beta)=\cos \alpha \cos \beta+\sin \alpha \sin \beta=-m-2m=-3m$,选 A。 - ---- - -### 题目5 -**题目序号**: 5 -**题目内容**: 已知圆柱和圆锥的底面半径相等,侧面积相等,且它们的高均为 $\sqrt{3}$,则圆锥的体积为 -**选项**: -A. $2\sqrt{3}\pi$ -B. $3\sqrt{3}\pi$ -C. $6\sqrt{3}\pi$ -D. $9\sqrt{3}\pi$ -**答案**: B -**解析**: 设它们底面半径为 $r$,圆锥母线 $l$,$\therefore 2\pi r\sqrt{3}=\pi rl$,$\therefore l=\sqrt{3}$,则圆锥的体积为 $\frac{1}{3}\pi r^{2}h$。 \ No newline at end of file +1. 题目序号:1 +2. 题目内容:已知集合 $A=\left\{x \mid -5 < x^{3} < 5\right\}, B=\left\{-3,-1,0,2,3\right\}$,则 $A \cap B=$ +3. 选项: + A. $\{-1,0\}$ + B. $\{2,3\}$ + C. $\{-3,-1,0\}$ + D. $\{-1,0,2\}$ +4. 答案:A +5. 解析:$A \cap B=\{-1,0\}$,选 A。 + +1. 题目序号:2 +2. 题目内容:若 $\frac{2}{z-1}=1+i$,则 $z=$ +3. 选项: + A. $-1-i$ + B. $-1+i$ + C. $1-i$ + D. $1+i$ +4. 答案:C +5. 解析: + +1. 题目序号:3 +2. 题目内容:已知向量 $\vec{a}=(0,1)$,$\vec{b}=(2,x)$,若 $\vec{b} \perp (\vec{b}-4\vec{a})$,则 $x=$ +3. 选项: + A. $-2$ + B. $-1$ + C. $1$ + D. $2$ +4. 答案:D +5. 解析:$\vec{b}-4\vec{a}=(2,x-4)$,$\vec{b} \perp (\vec{b}-4\vec{a})$,$\therefore \vec{b}(\vec{b}-4\vec{a})=0$,$\therefore 4+x(x-4)=0$,$\therefore x=2$,选 D。 + +1. 题目序号:4 +2. 题目内容:已知 $\cos(\alpha+\beta)=m$,$\tan \alpha \tan \beta=2$,则 $\cos(\alpha-\beta)=$ +3. 选项: + A. $-3m$ + B. $-\frac{m}{3}$ + C. $\frac{m}{3}$ + D. $3m$ +4. 答案:A +5. 解析:$\left\{\begin{array}{l}\cos \alpha \cos \beta-\sin \alpha \sin \beta=m \\\frac{\sin \alpha \sin \beta}{\cos \alpha \cos \beta}=2\end{array}\right.$,$\therefore \left\{\begin{array}{l}\sin \alpha \sin \beta=-2m \\\cos \alpha \cos \beta=-m\end{array}\right.$,$\cos(\alpha-\beta)=\cos \alpha \cos \beta+\sin \alpha \sin \beta=-m-2m=-3m$,选 A。 + +1. 题目序号:5 +2. 题目内容:已知圆柱和圆锥的底面半径相等,侧面积相等,且它们的高均为 $\sqrt{3}$,则圆锥的体积为 +3. 选项: + A. $2\sqrt{3}\pi$ + B. $3\sqrt{3}\pi$ + C. $6\sqrt{3}\pi$ + D. $9\sqrt{3}\pi$ +4. 答案:B +5. 解析:设它们底面半径为 $r$,圆锥母线 $l$,$\therefore 2\pi r\sqrt{3}=\pi rl$,$\therefore l=\sqrt{3}$,则圆锥的体积为 $\frac{1}{3}\pi r^{2}h$。 \ No newline at end of file diff --git a/dsLightRag/ShiTi/T4_DocxToMd.py b/dsLightRag/ShiTi/T3_DocxToMd.py similarity index 92% rename from dsLightRag/ShiTi/T4_DocxToMd.py rename to dsLightRag/ShiTi/T3_DocxToMd.py index 2e372b01..8265946d 100644 --- a/dsLightRag/ShiTi/T4_DocxToMd.py +++ b/dsLightRag/ShiTi/T3_DocxToMd.py @@ -3,7 +3,7 @@ import os import shutil from raganything import RAGAnything, RAGAnythingConfig -from Util.RagUtil import create_llm_model_func, create_vision_model_func, create_embedding_func +from Util.LightRagUtil import create_llm_model_func, create_embedding_func, create_vision_model_func import logging @@ -24,10 +24,10 @@ logger.addHandler(handler) async def main(): # 要处理的文件路径 file_path = "Docx/《动能定理》巩固练习.docx" - WORKING_DIR = "../../Topic/MathOcr" + WORKING_DIR = "../Topic/MathOcr" # 删除output目录下的所有文件 - output_dir = "../../output" + output_dir = "../output" shutil.rmtree(output_dir, ignore_errors=True) os.makedirs(output_dir, exist_ok=True) diff --git a/dsLightRag/Util/LightRagUtil.py b/dsLightRag/Util/LightRagUtil.py index 02555828..7524dbe4 100644 --- a/dsLightRag/Util/LightRagUtil.py +++ b/dsLightRag/Util/LightRagUtil.py @@ -139,4 +139,43 @@ def create_embedding_func(): api_key=EMBED_API_KEY, base_url=EMBED_BASE_URL, ), - ) \ No newline at end of file + ) + + +def create_vision_model_func(llm_model_func): + def vision_model_func( + prompt, system_prompt=None, history_messages=[], image_data=None, **kwargs + ): + if image_data: + return openai_complete_if_cache( + VISION_MODEL_NAME, + "", + system_prompt=None, + history_messages=[], + messages=[ + {"role": "system", "content": system_prompt} + if system_prompt + else None, + { + "role": "user", + "content": [ + {"type": "text", "text": prompt}, + { + "type": "image_url", + "image_url": { + "url": f"data:image/jpeg;base64,{image_data}" + }, + }, + ], + } + if image_data + else {"role": "user", "content": prompt}, + ], + api_key=VISION_API_KEY, + base_url=VISION_BASE_URL, + **kwargs, + ) + else: + return llm_model_func(prompt, system_prompt, history_messages, **kwargs) + + return vision_model_func \ No newline at end of file diff --git a/dsLightRag/Util/__pycache__/LightRagUtil.cpython-310.pyc b/dsLightRag/Util/__pycache__/LightRagUtil.cpython-310.pyc index cca97fca..f3a1e61a 100644 Binary files a/dsLightRag/Util/__pycache__/LightRagUtil.cpython-310.pyc and b/dsLightRag/Util/__pycache__/LightRagUtil.cpython-310.pyc differ