From 30821905af3ed5783dae28014262cda944c7974e Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 6 Jun 2025 21:36:01 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20remove=20default=20list=20param?= =?UTF-8?q?=EF=BC=8Cfix=20dashscope=5Fsource=20contexts=20params?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/provider/sources/anthropic_source.py | 4 +++- astrbot/core/provider/sources/dashscope_source.py | 2 ++ astrbot/core/provider/sources/dify_source.py | 4 +++- astrbot/core/provider/sources/llmtuner_source.py | 4 +++- astrbot/core/provider/sources/zhipu_source.py | 4 +++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/astrbot/core/provider/sources/anthropic_source.py b/astrbot/core/provider/sources/anthropic_source.py index 319515c52..c3ad45868 100644 --- a/astrbot/core/provider/sources/anthropic_source.py +++ b/astrbot/core/provider/sources/anthropic_source.py @@ -104,11 +104,13 @@ class ProviderAnthropic(ProviderOpenAIOfficial): session_id: str = None, image_urls: List[str] = [], func_tool: FuncCall = None, - contexts=[], + contexts=None, system_prompt=None, tool_calls_result: ToolCallsResult = None, **kwargs, ) -> LLMResponse: + if contexts is None: + contexts = [] if not prompt: prompt = "" diff --git a/astrbot/core/provider/sources/dashscope_source.py b/astrbot/core/provider/sources/dashscope_source.py index 2c4930692..f719190a1 100644 --- a/astrbot/core/provider/sources/dashscope_source.py +++ b/astrbot/core/provider/sources/dashscope_source.py @@ -74,6 +74,8 @@ class ProviderDashscope(ProviderOpenAIOfficial): system_prompt: str = None, **kwargs, ) -> LLMResponse: + if contexts is None: + contexts = [] # 获得会话变量 payload_vars = self.variables.copy() # 动态变量 diff --git a/astrbot/core/provider/sources/dify_source.py b/astrbot/core/provider/sources/dify_source.py index ad0605f14..619aae13d 100644 --- a/astrbot/core/provider/sources/dify_source.py +++ b/astrbot/core/provider/sources/dify_source.py @@ -61,12 +61,14 @@ class ProviderDify(Provider): self, prompt: str, session_id: str = None, - image_urls: List[str] = [], + image_urls: List[str] = None, func_tool: FuncCall = None, contexts: List = None, system_prompt: str = None, **kwargs, ) -> LLMResponse: + if image_urls is None: + image_urls = [] result = "" conversation_id = self.conversation_ids.get(session_id, "") diff --git a/astrbot/core/provider/sources/llmtuner_source.py b/astrbot/core/provider/sources/llmtuner_source.py index 85994fd59..8648512d0 100644 --- a/astrbot/core/provider/sources/llmtuner_source.py +++ b/astrbot/core/provider/sources/llmtuner_source.py @@ -60,10 +60,12 @@ class LLMTunerModelLoader(Provider): session_id: str = None, image_urls: List[str] = None, func_tool: FuncCall = None, - contexts: List = [], + contexts: List = None, system_prompt: str = None, **kwargs, ) -> LLMResponse: + if contexts is None: + contexts = [] system_prompt = "" new_record = {"role": "user", "content": prompt} query_context = [*contexts, new_record] diff --git a/astrbot/core/provider/sources/zhipu_source.py b/astrbot/core/provider/sources/zhipu_source.py index 2f7490317..e7e9d4a14 100644 --- a/astrbot/core/provider/sources/zhipu_source.py +++ b/astrbot/core/provider/sources/zhipu_source.py @@ -31,10 +31,12 @@ class ProviderZhipu(ProviderOpenAIOfficial): session_id: str = None, image_urls: List[str] = None, func_tool: FuncCall = None, - contexts=[], + contexts=None, system_prompt=None, **kwargs, ) -> LLMResponse: + if contexts is None: + contexts = [] new_record = await self.assemble_context(prompt, image_urls) context_query = []