Fix mutable default arguments in constructors and methods (#3247)

* Initial plan

* Fix mutable default arguments in constructors and methods

Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com>
This commit is contained in:
Copilot
2025-11-02 12:57:37 +08:00
committed by GitHub
parent c8e34ff26f
commit 92abc43c9d
4 changed files with 19 additions and 7 deletions
+6 -2
View File
@@ -320,8 +320,8 @@ class AstrMessageEvent(abc.ABC):
prompt: str,
func_tool_manager=None,
session_id: str = None,
image_urls: list[str] = [],
contexts: list = [],
image_urls: list[str] | None = None,
contexts: list | None = None,
system_prompt: str = "",
conversation: Conversation = None,
) -> ProviderRequest:
@@ -346,6 +346,10 @@ class AstrMessageEvent(abc.ABC):
conversation: 可选。如果指定,将在指定的对话中进行 LLM 请求。对话的人格会被用于 LLM 请求,并且结果将会被记录到对话中。
"""
if image_urls is None:
image_urls = []
if contexts is None:
contexts = []
if len(contexts) > 0 and conversation:
conversation = None
@@ -66,13 +66,15 @@ class ProviderDashscope(ProviderOpenAIOfficial):
self,
prompt: str,
session_id=None,
image_urls=[],
image_urls=None,
func_tool=None,
contexts=None,
system_prompt=None,
model=None,
**kwargs,
) -> LLMResponse:
if image_urls is None:
image_urls = []
if contexts is None:
contexts = []
# 获得会话变量
+4 -2
View File
@@ -36,11 +36,13 @@ class CommandFilter(HandlerFilter):
command_name: str,
alias: set | None = None,
handler_md: StarHandlerMetadata | None = None,
parent_command_names: list[str] = [""],
parent_command_names: list[str] | None = None,
):
self.command_name = command_name
self.alias = alias if alias else set()
self.parent_command_names = parent_command_names
self.parent_command_names = (
parent_command_names if parent_command_names is not None else [""]
)
if handler_md:
self.init_handler_md(handler_md)
self.custom_filter_list: list[CustomFilter] = []
+6 -2
View File
@@ -46,9 +46,11 @@ class DifyAPIClient:
user: str,
response_mode: str = "streaming",
conversation_id: str = "",
files: list[dict[str, Any]] = [],
files: list[dict[str, Any]] | None = None,
timeout: float = 60,
) -> AsyncGenerator[dict[str, Any], None]:
if files is None:
files = []
url = f"{self.api_base}/chat-messages"
payload = locals()
payload.pop("self")
@@ -73,9 +75,11 @@ class DifyAPIClient:
inputs: dict,
user: str,
response_mode: str = "streaming",
files: list[dict[str, Any]] = [],
files: list[dict[str, Any]] | None = None,
timeout: float = 60,
):
if files is None:
files = []
url = f"{self.api_base}/workflows/run"
payload = locals()
payload.pop("self")