main
HuangHai 2 weeks ago
parent 88e0a14e67
commit 014227c918

@ -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()

@ -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": "帮我写一下 如何理解点、线、面、体、角 的教学设计"
}
}
}

@ -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,

Loading…
Cancel
Save