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 = []