diff --git a/dsRagAnything/.idea/PythonProject.iml b/dsRagAnything/.idea/PythonProject.iml index 522e9aee..e7208d28 100644 --- a/dsRagAnything/.idea/PythonProject.iml +++ b/dsRagAnything/.idea/PythonProject.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/dsRagAnything/.idea/misc.xml b/dsRagAnything/.idea/misc.xml index 95f02ad8..0827f803 100644 --- a/dsRagAnything/.idea/misc.xml +++ b/dsRagAnything/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc b/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc index a5ce430f..903a9b7a 100644 Binary files a/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc and b/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc differ diff --git a/dsRagAnything/Config/__pycache__/__init__.cpython-310.pyc b/dsRagAnything/Config/__pycache__/__init__.cpython-310.pyc index 0f31ec8d..c2453eac 100644 Binary files a/dsRagAnything/Config/__pycache__/__init__.cpython-310.pyc and b/dsRagAnything/Config/__pycache__/__init__.cpython-310.pyc differ diff --git a/dsRagAnything/T2_Query.py b/dsRagAnything/T2_Query.py index c1e292d6..0952d6a8 100644 --- a/dsRagAnything/T2_Query.py +++ b/dsRagAnything/T2_Query.py @@ -6,12 +6,10 @@ from lightrag import LightRAG from lightrag.llm.openai import openai_complete_if_cache, openai_embed from lightrag.utils import EmbeddingFunc import os +from Config.Config import * -async def load_existing_lightrag(): - # 设置 API 配置 - api_key = "sk-44ae895eeb614aa1a9c6460579e322f1" - base_url = "https://api.deepseek.com" # Optional +async def load_existing_lightrag(): # 首先,创建或加载已存在的 LightRAG 实例 lightrag_working_dir = "./rag_storage" @@ -29,8 +27,8 @@ async def load_existing_lightrag(): prompt, system_prompt=system_prompt, history_messages=history_messages, - api_key=api_key, - base_url=base_url, + api_key=LLM_API_KEY, + base_url=LLM_BASE_URL, **kwargs, ), embedding_func=EmbeddingFunc( @@ -38,9 +36,9 @@ async def load_existing_lightrag(): max_token_size=8192, func=lambda texts: openai_embed( texts, - model="BAAI/bge-m3", - api_key="sk-pbqibyjwhrgmnlsmdygplahextfaclgnedetybccknxojlyl", - base_url="https://api.siliconflow.cn/v1", + model=EMBED_MODEL_NAME, + api_key=EMBED_API_KEY, + base_url=EMBED_BASE_URL, ), ) ) @@ -51,11 +49,13 @@ async def load_existing_lightrag(): # 定义视觉模型函数用于图像处理 def vision_model_func( - prompt, system_prompt=None, history_messages=[], image_data=None, **kwargs + prompt, system_prompt=None, history_messages=None, image_data=None, **kwargs ): + if history_messages is None: + history_messages = [] if image_data: return openai_complete_if_cache( - "GLM-4.1V-9B-Thinking", + VISION_MODEL_NAME, "", system_prompt=None, history_messages=[], @@ -78,8 +78,8 @@ async def load_existing_lightrag(): if image_data else {"role": "user", "content": prompt}, ], - api_key="sk-pbqibyjwhrgmnlsmdygplahextfaclgnedetybccknxojlyl", - base_url="https://api.siliconflow.cn/v1/chat/completions", + api_key=VISION_API_KEY, + base_url=VISION_BASE_URL, **kwargs, ) else: @@ -94,7 +94,7 @@ async def load_existing_lightrag(): # 查询已存在的知识库 result = await rag.aquery( - #"黄琬乔的准考证信息告诉我一下?", + # "黄琬乔的准考证信息告诉我一下?", "平台安全的保证方法有哪些?", mode="hybrid" ) @@ -106,5 +106,6 @@ async def load_existing_lightrag(): # output_dir="./output" # ) + if __name__ == "__main__": - asyncio.run(load_existing_lightrag()) \ No newline at end of file + asyncio.run(load_existing_lightrag())