Skip to content

Commit

Permalink
Removed redundant data argument for the python tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Shulyaka committed Dec 11, 2024
1 parent 7965e0f commit 2b65273
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions custom_components/powerllm/tools/python_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def emit(self, record: logging.LogRecord):


@llm_tool
def python_code_execute(hass: HomeAssistant, source: str, data: dict | None = None):
def python_code_execute(hass: HomeAssistant, source: str):
"""Execute python code in a restricted environment.
Use this tool for math calculations among other things.
Expand All @@ -54,7 +54,7 @@ def python_code_execute(hass: HomeAssistant, source: str, data: dict | None = No
logger.addHandler(log_handler)
try:
printed = []
output = execute(hass, source, data, printed)
output = execute(hass, source, printed)
except HomeAssistantError as e:
output = {"error": type(e).__name__}
if str(e):
Expand Down Expand Up @@ -160,7 +160,7 @@ def guarded_inplacevar(op: str, target: Any, operand: Any) -> Any:
return op_fun(target, operand)


def execute(hass, source, data=None, printed: list[str] | None = None):
def execute(hass, source, printed: list[str] | None = None):
"""Execute Python source."""

if printed is None:
Expand Down Expand Up @@ -279,13 +279,12 @@ def protected_getattr(obj, name, default=raise_):
"_unpack_sequence_": guarded_unpack_sequence,
"_inplacevar_": guarded_inplacevar,
"hass": hass,
"data": data or {},
"logger": logger,
"output": {},
}

try:
_LOGGER.info("Executing script: %s", data)
_LOGGER.info("Executing script")
# pylint: disable-next=exec-used
exec(compiled.code, restricted_globals) # noqa: S102
_LOGGER.debug(
Expand Down

0 comments on commit 2b65273

Please sign in to comment.