From 0b381e25708b55e5afc7aee55a48665d9d9b328d Mon Sep 17 00:00:00 2001 From: Raila23 <3271405327@qq.com> Date: Wed, 9 Apr 2025 22:10:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=8D=E7=BD=AE=E9=A1=B9?= =?UTF-8?q?=EF=BC=8C=E5=85=81=E8=AE=B8=E9=85=8D=E7=BD=AE=EF=BC=9A=E8=B6=85?= =?UTF-8?q?=E5=87=BA=E6=9C=80=E5=A4=9A=E6=90=BA=E5=B8=A6=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E6=95=B0=E9=87=8F=20=E6=97=B6=EF=BC=8C=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E6=80=A7=E4=B8=A2=E5=BC=83=E5=A4=9A=E5=B0=91=E6=9D=A1=E6=97=A7?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/pipeline/process_stage/method/llm_request.py | 5 ++++- 1 file changed, 4 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 c6a87b37c..35e9f5f50 100644 --- a/astrbot/core/pipeline/process_stage/method/llm_request.py +++ b/astrbot/core/pipeline/process_stage/method/llm_request.py @@ -38,6 +38,9 @@ class LLMRequestSubStage(Stage): self.max_context_length = ctx.astrbot_config["provider_settings"][ "max_context_length" ] # int + self.dequeue_context_length = ctx.astrbot_config["provider_settings"][ + "dequeue_context_length" + ] # int self.streaming_response = ctx.astrbot_config["provider_settings"][ "streaming_response" ] # bool @@ -135,7 +138,7 @@ class LLMRequestSubStage(Stage): and len(req.contexts) // 2 > self.max_context_length ): logger.debug("上下文长度超过限制,将截断。") - req.contexts = req.contexts[-self.max_context_length * 2 :] + req.contexts = req.contexts[-(self.max_context_length - self.dequeue_context_length) * 2 :] # session_id if not req.session_id: