From 4e5517a602d1a23bcf3797f1e7793401167a0976 Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 15 Jan 2025 18:27:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Drag=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lightrag/api/lightrag_ollama.py | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/lightrag/api/lightrag_ollama.py b/lightrag/api/lightrag_ollama.py index 3c7da1ea..39c8256a 100644 --- a/lightrag/api/lightrag_ollama.py +++ b/lightrag/api/lightrag_ollama.py @@ -658,31 +658,14 @@ def create_app(args): # 解析查询模式 cleaned_query, mode = parse_query_mode(query) - # 构建系统提示词(如果有历史消息) - system_prompt = None - history_messages = [] - if len(messages) > 1: - # 如果第一条消息是系统消息,提取为system_prompt - if messages[0].role == "system": - system_prompt = messages[0].content - messages = messages[1:] - - # 收集历史消息(除了最后一条) - history_messages = [(msg.role, msg.content) for msg in messages[:-1]] - # 调用RAG进行查询 - kwargs = { - "param": QueryParam( + response = await rag.aquery( + cleaned_query, + param=QueryParam( mode=mode, stream=request.stream, ) - } - if system_prompt is not None: - kwargs["system_prompt"] = system_prompt - if history_messages: - kwargs["history_messages"] = history_messages - - response = await rag.aquery(cleaned_query, **kwargs) + ) if request.stream: async def stream_generator():