From 59fbbd5987adbde543aa0611ac746908e7c55e55 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sun, 2 Mar 2025 19:52:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20request=5Fllm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pipeline/process_stage/method/llm_request.py | 3 +++ astrbot/core/platform/astr_message_event.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/astrbot/core/pipeline/process_stage/method/llm_request.py b/astrbot/core/pipeline/process_stage/method/llm_request.py index 37e76f1eb..f17c7d7bb 100644 --- a/astrbot/core/pipeline/process_stage/method/llm_request.py +++ b/astrbot/core/pipeline/process_stage/method/llm_request.py @@ -39,6 +39,9 @@ class LLMRequestSubStage(Stage): if event.get_extra("provider_request"): req = event.get_extra("provider_request") assert isinstance(req, ProviderRequest), "provider_request 必须是 ProviderRequest 类型。" + + if req.conversation: + req.contexts = json.loads(req.conversation.history) else: req = ProviderRequest(prompt="", image_urls=[]) if self.provider_wake_prefix: diff --git a/astrbot/core/platform/astr_message_event.py b/astrbot/core/platform/astr_message_event.py index 0500d0279..05ffac6f8 100644 --- a/astrbot/core/platform/astr_message_event.py +++ b/astrbot/core/platform/astr_message_event.py @@ -327,12 +327,23 @@ class AstrMessageEvent(abc.ABC): yield event.request_llm(prompt="hi") ``` prompt: 提示词 + + system_prompt: 系统提示词 + session_id: 已经过时,留空即可 + image_urls: 可以是 base64:// 或者 http:// 开头的图片链接,也可以是本地图片路径。 - contexts: 当指定 contexts 时,将会使用 contexts 作为上下文。 + + contexts: 当指定 contexts 时,将会使用 contexts 作为上下文。如果同时传入了 conversation,将会忽略 conversation。 + func_tool_manager: 函数工具管理器,用于调用函数工具。用 self.context.get_llm_tool_manager() 获取。 + conversation: 可选。如果指定,将在指定的对话中进行 LLM 请求。对话的人格会被用于 LLM 请求,并且结果将会被记录到对话中。 ''' + + if len(contexts) > 0 and conversation: + conversation = None + return ProviderRequest( prompt = prompt, session_id = session_id,