diff --git a/dsRagAnything/Config/Config.py b/dsRagAnything/Config/Config.py index e8735d6d..e3ad3fef 100644 --- a/dsRagAnything/Config/Config.py +++ b/dsRagAnything/Config/Config.py @@ -16,18 +16,18 @@ GLM_API_KEY = "sk-pbqibyjwhrgmnlsmdygplahextfaclgnedetybccknxojlyl" GLM_MODEL_NAME = "THUDM/GLM-4.1V-9B-Thinking" # 阿里云API信息【YLT】 -#ALY_LLM_API_KEY = "sk-f6da0c787eff4b0389e4ad03a35a911f" +# ALY_LLM_API_KEY = "sk-f6da0c787eff4b0389e4ad03a35a911f" # 阿里云API信息【绘智科技】 ALY_LLM_API_KEY = "sk-01d13a39e09844038322108ecdbd1bbc" ALY_LLM_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1" -ALY_LLM_MODEL_NAME = "qwen-plus" - - +# 通义千问 +# ALY_LLM_MODEL_NAME = "qwen-plus" +# Kimi K2大模型 +ALY_LLM_MODEL_NAME = "Moonshot-Kimi-K2-Instruct" # 智谱的API KEY【吴缤申请个人版免费】 ZHIPU_API_KEY = "78dc1dfe37e04f29bd4ca9a49858a969.gn7TIZTfzpY35nx9" # GPTNB的API KEY GPTNB_API_KEY = "sk-amQHwiEzPIZIB2KuF5A10dC23a0e4b02B48a7a2b6aFa0662" -GPTNB_BASE_URL="https://goapi.gptnb.ai" - +GPTNB_BASE_URL = "https://goapi.gptnb.ai" diff --git a/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc b/dsRagAnything/Config/__pycache__/Config.cpython-310.pyc index 15276ce7..5099f04f 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/Doc/GeoGebra5经典版指令汇编201903061.pdf b/dsRagAnything/Doc/GeoGebra5经典版指令汇编201903061.pdf new file mode 100644 index 00000000..795c3748 Binary files /dev/null and b/dsRagAnything/Doc/GeoGebra5经典版指令汇编201903061.pdf differ diff --git a/dsRagAnything/Test.py b/dsRagAnything/Test.py index 70b6eb37..37fbeb58 100644 --- a/dsRagAnything/Test.py +++ b/dsRagAnything/Test.py @@ -3,10 +3,13 @@ from raganything import RAGAnything, RAGAnythingConfig from lightrag.llm.openai import openai_complete_if_cache, openai_embed from lightrag.utils import EmbeddingFunc +import Config.Config + + async def main(): # 设置 API 配置 - api_key = "your-api-key" - base_url = "your-base-url" # 可选 + api_key = Config.Config.ALY_LLM_API_KEY + base_url = Config.Config.ALY_LLM_BASE_URL # 创建 RAGAnything 配置 config = RAGAnythingConfig( @@ -21,7 +24,7 @@ async def main(): # 定义 LLM 模型函数 def llm_model_func(prompt, system_prompt=None, history_messages=[], **kwargs): return openai_complete_if_cache( - "gpt-4o-mini", + Config.Config.ALY_LLM_MODEL_NAME, prompt, system_prompt=system_prompt, history_messages=history_messages, @@ -32,24 +35,24 @@ async def main(): # 定义视觉模型函数用于图像处理 def vision_model_func( - prompt, system_prompt=None, history_messages=[], image_data=None, messages=None, **kwargs + prompt, system_prompt=None, history_messages=[], image_data=None, messages=None, **kwargs ): # 如果提供了messages格式(用于多模态VLM增强查询),直接使用 if messages: return openai_complete_if_cache( - "gpt-4o", + Config.Config.GLM_MODEL_NAME, "", system_prompt=None, history_messages=[], messages=messages, - api_key=api_key, - base_url=base_url, + api_key=Config.Config.GLM_API_KEY, + base_url=Config.Config.GLM_BASE_URL, **kwargs, ) # 传统单图片格式 elif image_data: return openai_complete_if_cache( - "gpt-4o", + Config.Config.GLM_MODEL_NAME, "", system_prompt=None, history_messages=[], @@ -72,8 +75,8 @@ async def main(): if image_data else {"role": "user", "content": prompt}, ], - api_key=api_key, - base_url=base_url, + api_key=Config.Config.GLM_API_KEY, + base_url=Config.Config.GLM_BASE_URL, **kwargs, ) # 纯文本格式 @@ -82,13 +85,13 @@ async def main(): # 定义嵌入函数 embedding_func = EmbeddingFunc( - embedding_dim=3072, - max_token_size=8192, + embedding_dim=Config.Config.EMBED_DIM, + max_token_size=Config.Config.EMBED_MAX_TOKEN_SIZE, func=lambda texts: openai_embed( texts, - model="text-embedding-3-large", - api_key=api_key, - base_url=base_url, + model=Config.Config.EMBED_MODEL_NAME, + api_key=Config.Config.EMBED_API_KEY, + base_url=Config.Config.EMBED_BASE_URL, ), ) @@ -102,7 +105,7 @@ async def main(): # 处理文档 await rag.process_document_complete( - file_path="path/to/your/document.pdf", + file_path="./Doc/GeoGebra5经典版指令汇编201903061.pdf", output_dir="./output", parse_method="auto" ) @@ -115,19 +118,6 @@ async def main(): ) print("文本查询结果:", text_result) - # 多模态查询 - 包含具体多模态内容的查询 - multimodal_result = await rag.aquery_with_multimodal( - "分析这个性能数据并解释与现有文档内容的关系", - multimodal_content=[{ - "type": "table", - "table_data": """系统,准确率,F1分数 - RAGAnything,95.2%,0.94 - 基准方法,87.3%,0.85""", - "table_caption": "性能对比结果" - }], - mode="hybrid" - ) - print("多模态查询结果:", multimodal_result) if __name__ == "__main__": - asyncio.run(main()) \ No newline at end of file + asyncio.run(main())