@@ -54,6 +54,10 @@ def execute_function(self, function_name: str, parameters: dict[str, Any]) -> No
5454 1. time.sleep() - to wait for web pages, applications, and other things to load.
5555 2. pyautogui calls to interact with system's mouse and keyboard.
5656 """
57+ # Strip to bare name to normalize
58+ if function_name .startswith ('pyautogui.' ):
59+ function_name = function_name .split ('.' )[- 1 ]
60+
5761 # Sometimes pyautogui needs warming up i.e. sometimes first call isn't executed hence padding a random call here
5862 pyautogui .press ("command" , interval = 0.2 )
5963
@@ -64,9 +68,9 @@ def execute_function(self, function_name: str, parameters: dict[str, Any]) -> No
6468 function_to_call = getattr (pyautogui , function_name )
6569
6670 # Special handling for the 'write' function
67- if function_name == 'write' and ('string' in parameters or 'text' in parameters ):
71+ if function_name == 'write' and ('string' in parameters or 'text' in parameters or 'message' in parameters ):
6872 # 'write' function expects a string, not a 'text' keyword argument but LLM sometimes gets confused on the parameter name.
69- string_to_write = parameters .get ('string' ) or parameters .get ('text' )
73+ string_to_write = parameters .get ('string' ) or parameters .get ('text' ) or parameters . get ( 'message' )
7074 interval = parameters .get ('interval' , 0.1 )
7175 function_to_call (string_to_write , interval = interval )
7276 elif function_name == 'press' and ('keys' in parameters or 'key' in parameters ):
@@ -77,8 +81,14 @@ def execute_function(self, function_name: str, parameters: dict[str, Any]) -> No
7781 function_to_call (keys_to_press , presses = presses , interval = interval )
7882 elif function_name == 'hotkey' :
7983 # 'hotkey' function expects multiple key arguments, not a list
80- keys = list (parameters .values ())
81- function_to_call (* keys )
84+ keys_to_press = parameters .get ('keys' ) or parameters .get ('key' )
85+ if isinstance (keys_to_press , list ):
86+ function_to_call (* keys_to_press )
87+ elif isinstance (keys_to_press , str ):
88+ function_to_call (keys_to_press )
89+ else :
90+ keys = list (parameters .values ())
91+ function_to_call (* keys )
8292 else :
8393 # For other functions, pass the parameters as they are
8494 function_to_call (** parameters )
0 commit comments