From 014227c9187c1960e974e37834e124f815de5780 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Tue, 8 Jul 2025 15:19:57 +0800 Subject: [PATCH] 'commit' --- dsRagAnything/Start.py | 14 ++++---- .../Math/kv_store_llm_response_cache.json | 30 ++++++++++++++++++ dsRagAnything/Util/RagUtil.py | 4 +-- .../Util/__pycache__/RagUtil.cpython-310.pyc | Bin 1841 -> 1869 bytes 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/dsRagAnything/Start.py b/dsRagAnything/Start.py index daceacd6..fdd44bff 100644 --- a/dsRagAnything/Start.py +++ b/dsRagAnything/Start.py @@ -14,7 +14,6 @@ from starlette.staticfiles import StaticFiles from Util.RagUtil import create_llm_model_func, create_vision_model_func, create_embedding_func - import logging # 在程序开始时添加以下配置 @@ -50,19 +49,20 @@ app.mount("/static", StaticFiles(directory="Static"), name="static") @app.post("/api/rag") async def rag(request: fastapi.Request): data = await request.json() - topic = data.get("topic") # Chinese, Math + topic = data.get("topic") # Chinese, Math # 拼接路径 - WORKING_PATH= "./Topic/" + topic + WORKING_PATH = "./Topic/" + topic # 查询的问题 query = data.get("query") - # 关闭参考资料 - user_prompt="\n 1、不要输出参考资料 或者 References !" - user_prompt = user_prompt + "\n 2、如果问题与提供的知识库内容不符,则明确告诉未在知识库范围内提到!" async def generate_response_stream(query: str): + # 关闭参考资料 + user_prompt = "\n 1、不要输出参考资料 或者 References !" + user_prompt = user_prompt + "\n 2、如果问题与提供的知识库内容不符,则明确告诉未在知识库范围内提到!" + try: # 初始化RAG组件 - llm_model_func = create_llm_model_func() + llm_model_func = create_llm_model_func(v_history_messages=[]) vision_model_func = create_vision_model_func(llm_model_func) embedding_func = create_embedding_func() diff --git a/dsRagAnything/Topic/Math/kv_store_llm_response_cache.json b/dsRagAnything/Topic/Math/kv_store_llm_response_cache.json index 6017ea4d..fd0bcaed 100644 --- a/dsRagAnything/Topic/Math/kv_store_llm_response_cache.json +++ b/dsRagAnything/Topic/Math/kv_store_llm_response_cache.json @@ -2361,6 +2361,36 @@ "embedding_min": null, "embedding_max": null, "original_prompt": "小学数学中有哪些常见模型?\n 1、不要输出参考资料 或者 References !\n 2、如果问题与提供的知识库内容不符,则明确告诉未在知识库范围内提到!" + }, + "0eea3a1f6f9b9c5cc3fc45c951cdff0b": { + "return": "{\"high_level_keywords\": [\"\\u5c0f\\u5b66\\u6570\\u5b66\", \"\\u5e38\\u89c1\\u6a21\\u578b\", \"\\u6570\\u5b66\\u6559\\u80b2\"], \"low_level_keywords\": [\"\\u52a0\\u51cf\\u6cd5\\u6a21\\u578b\", \"\\u4e58\\u9664\\u6cd5\\u6a21\\u578b\", \"\\u51e0\\u4f55\\u56fe\\u5f62\", \"\\u5206\\u6570\\u6a21\\u578b\", \"\\u5e94\\u7528\\u9898\"]}", + "cache_type": "keywords", + "chunk_id": null, + "embedding": null, + "embedding_shape": null, + "embedding_min": null, + "embedding_max": null, + "original_prompt": "小学数学中有哪些常见模型?" + }, + "b9740bbeac02754d4505acd46e21f520": { + "return": "{\"high_level_keywords\": [\"\\u6a21\\u578b\\u89e3\\u91ca\", \"\\u8be6\\u7ec6\\u8bf4\\u660e\"], \"low_level_keywords\": [\"\\u7b2c\\u4e8c\\u4e2a\\u6a21\\u578b\"]}", + "cache_type": "keywords", + "chunk_id": null, + "embedding": null, + "embedding_shape": null, + "embedding_min": null, + "embedding_max": null, + "original_prompt": "第二个模型详细解释一下" + }, + "39927327159cfd7cca859e211cc6e357": { + "return": "{\"high_level_keywords\": [\"\\u6559\\u5b66\\u8bbe\\u8ba1\", \"\\u51e0\\u4f55\\u6982\\u5ff5\", \"\\u57fa\\u7840\\u6570\\u5b66\"], \"low_level_keywords\": [\"\\u70b9\", \"\\u7ebf\", \"\\u9762\", \"\\u4f53\", \"\\u89d2\"]}", + "cache_type": "keywords", + "chunk_id": null, + "embedding": null, + "embedding_shape": null, + "embedding_min": null, + "embedding_max": null, + "original_prompt": "帮我写一下 如何理解点、线、面、体、角 的教学设计" } } } \ No newline at end of file diff --git a/dsRagAnything/Util/RagUtil.py b/dsRagAnything/Util/RagUtil.py index 59648fb1..09e29372 100644 --- a/dsRagAnything/Util/RagUtil.py +++ b/dsRagAnything/Util/RagUtil.py @@ -4,13 +4,13 @@ from lightrag.utils import EmbeddingFunc from Config.Config import * -def create_llm_model_func(): +def create_llm_model_func(v_history_messages): def llm_model_func(prompt, system_prompt=None, history_messages=[], **kwargs): return openai_complete_if_cache( LLM_MODEL_NAME, prompt, system_prompt=system_prompt, - history_messages=history_messages, + history_messages=v_history_messages, api_key=LLM_API_KEY, base_url=LLM_BASE_URL, **kwargs, diff --git a/dsRagAnything/Util/__pycache__/RagUtil.cpython-310.pyc b/dsRagAnything/Util/__pycache__/RagUtil.cpython-310.pyc index e1127517c160b34d27a658c71e321ff8094e024f..31ea27cbe75d4d63951431b9761c6e4accf55c2e 100644 GIT binary patch delta 348 zcmdnUcb1PgpO=@50SL;E#0Mfz^#L_@qECVD;7)lsxfEsHUI~XPlG0qTUyd_i?pOINy zl3!FApPO1-oS2?kymIn-#>q1LK=qnTMSMW2NDxGT1d4b;guvuTCS^7uMi%ZOq0LQ9 z%#4f@liQf}*(5=dQj>QxH}I`wMA9TM*`1{qW+2!sdANac5CcE3=rSrymSa7}4YmeM m2uyy@S|NboLj}v(^cdAAFJtqP7Xs;301@gS0z)M~yAlAjCp)kJ delta 329 zcmX@hw~>!GpO=@50SGKQvoqKx@~(^labSQE$Y2IyXCN*X0um_<=?rO1DU2yhEsV7c zH4MQFn#_L5ASE!s0%WiQaWoJY%K(WIh7!gapr#te8m7r&j5Amnig+0qCLdv(EDod@ zRx%dx11XRgl;E3O%%sf5$H>B6B)EAF6Eh>D_~Zr5`fL&)6_S&$GB@xP2_UIXX6cmy z>DFX|m?R6A1FPbj%)_e7C^y-P^%ys@CERQkq6j{i#Rt@ROLVe6o9N`VY$A-RlMk_Z W$qRyvlLHZ|aDx&0_$F(!D**s*3NhvY