Spaces:
Paused
Paused
changing a field name from `code` to `input`. Reduces the problem of the model constantly trying to write code rather than calling tools
Browse files123 unmodified lines1241251261271281291301 unmodified line13213313413513613713813928 unmodified lines1681691701711721731747 unmodified lines182183184185186187188123 unmodified lines@autodoc(summary=TOOL_SUMMARY,)def Agent_Terminal(code: Annotated[str, ("Python source code to run; stdout is captured and returned. ""Execute these commands: ""`search_tools('query')` to search for tools by name or capability; "1 unmodified line"`usage('ToolName')` to inspect a tool’s expected input parameters; ""`search_packages('query')` to search for installed Python libraries.")]) -> str:_log_call_start("Agent_Terminal", code=_truncate_for_log(code or "", 300))if code is None:result = "No code provided."_log_call_end("Agent_Terminal", result)return result28 unmodified linesos.chdir(ROOT_DIR)# Parse code to check if the last statement is an expressiontree = ast.parse(code)if tree.body and isinstance(tree.body[-1], ast.Expr):last_node = tree.body.pop()7 unmodified linesif result_val is not None:print(result_val)else:exec(code, tools_env)result = redirected_output.getvalue()except Exception as exc: # pylint: disable=broad-except123 unmodified lines1241251261271281291301 unmodified line13213313413513613713813928 unmodified lines1681691701711721731747 unmodified lines182183184185186187188123 unmodified lines@autodoc(summary=TOOL_SUMMARY,)def Agent_Terminal(input: Annotated[str, ("Python source code to run; stdout is captured and returned. ""Execute these commands: ""`search_tools('query')` to search for tools by name or capability; "1 unmodified line"`usage('ToolName')` to inspect a tool’s expected input parameters; ""`search_packages('query')` to search for installed Python libraries.")]) -> str:_log_call_start("Agent_Terminal", input=_truncate_for_log(input or "", 300))if input is None:result = "No code provided."_log_call_end("Agent_Terminal", result)return result28 unmodified linesos.chdir(ROOT_DIR)# Parse code to check if the last statement is an expressiontree = ast.parse(input)if tree.body and isinstance(tree.body[-1], ast.Expr):last_node = tree.body.pop()7 unmodified linesif result_val is not None:print(result_val)else:exec(input, tools_env)result = redirected_output.getvalue()except Exception as exc: # pylint: disable=broad-except
Modules/Agent_Terminal.py+5-5