Skip to content

Commit f37777d

Browse files
committed
refactor: use module-level constant for OS name as suggested in PR review
1 parent c4dc8e3 commit f37777d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

astrbot/core/computer/tools/python.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from astrbot.core.computer.tools.permissions import check_admin_permission
1212
from astrbot.core.message.message_event_result import MessageChain
1313

14+
_OS_NAME = platform.system()
15+
1416
param_schema = {
1517
"type": "object",
1618
"properties": {
@@ -62,9 +64,7 @@ async def handle_result(result: dict, event: AstrMessageEvent) -> ToolExecResult
6264
@dataclass
6365
class PythonTool(FunctionTool):
6466
name: str = "astrbot_execute_ipython"
65-
description: str = (
66-
f"Run codes in an IPython shell. Current OS: {platform.system()}."
67-
)
67+
description: str = f"Run codes in an IPython shell. Current OS: {_OS_NAME}."
6868
parameters: dict = field(default_factory=lambda: param_schema)
6969

7070
async def call(
@@ -86,7 +86,10 @@ async def call(
8686
@dataclass
8787
class LocalPythonTool(FunctionTool):
8888
name: str = "astrbot_execute_python"
89-
description: str = f"Execute codes in a Python environment. Current OS: {platform.system()}. Use system-compatible commands."
89+
description: str = (
90+
f"Execute codes in a Python environment. Current OS: {_OS_NAME}. "
91+
"Use system-compatible commands."
92+
)
9093

9194
parameters: dict = field(default_factory=lambda: param_schema)
9295

0 commit comments

Comments
 (0)