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answer to the problem
|
| 7 |
+
\"\"\"
|
| 8 |
+
|
| 9 |
+
def move_mouse(self, x: float, y: float) -> str:
|
| 10 |
+
\"\"\"
|
| 11 |
+
Moves the mouse cursor to the specified coordinates
|
| 12 |
+
Args:
|
| 13 |
+
x: The x coordinate (horizontal position)
|
| 14 |
+
y: The y coordinate (vertical position)
|
| 15 |
+
\"\"\"
|
| 16 |
+
|
| 17 |
+
def click(x: Optional[float] = None, y: Optional[float] = None) -> str:
|
| 18 |
+
\"\"\"
|
| 19 |
+
Performs a left-click at the specified normalized coordinates
|
| 20 |
+
Args:
|
| 21 |
+
x: The x coordinate (horizontal position)
|
| 22 |
+
y: The y coordinate (vertical position)
|
| 23 |
+
\"\"\"
|
| 24 |
+
|
| 25 |
+
def double_click(x: Optional[float] = None, y: Optional[float] = None) -> str:
|
| 26 |
+
\"\"\"
|
| 27 |
+
Performs a double-click at the specified normalized coordinates
|
| 28 |
+
Args:
|
| 29 |
+
x: The x coordinate (horizontal position)
|
| 30 |
+
y: The y coordinate (vertical position)
|
| 31 |
+
\"\"\"
|
| 32 |
+
|
| 33 |
+
def type(text: str) -> str:
|
| 34 |
+
\"\"\"
|
| 35 |
+
Types the specified text at the current cursor position.
|
| 36 |
+
Args:
|
| 37 |
+
text: The text to type
|
| 38 |
+
\"\"\"
|
| 39 |
+
|
| 40 |
+
def press(keys: str | list[str]) -> str:
|
| 41 |
+
\"\"\"
|
| 42 |
+
Presses a keyboard key
|
| 43 |
+
Args:
|
| 44 |
+
keys: The key or list of keys to press (e.g. "enter", "space", "backspace", "ctrl", etc.).
|
| 45 |
+
\"\"\"
|
| 46 |
+
|
| 47 |
+
def navigate_back() -> str:
|
| 48 |
+
\"\"\"
|
| 49 |
+
Goes back to the previous page in the browser. If using this tool doesn't work, just click the button directly.
|
| 50 |
+
\"\"\"
|
| 51 |
+
|
| 52 |
+
def drag(from_coord: list[float], to_coord: list[float]) -> str:
|
| 53 |
+
\"\"\"
|
| 54 |
+
Clicks [x1, y1], drags mouse to [x2, y2], then release click.
|
| 55 |
+
Args:
|
| 56 |
+
x1: origin x coordinate
|
| 57 |
+
y1: origin y coordinate
|
| 58 |
+
x2: end x coordinate
|
| 59 |
+
y2: end y coordinate
|
| 60 |
+
\"\"\"
|
| 61 |
+
|
| 62 |
+
def scroll(direction: Literal["up", "down"] = "down", amount: int = 1) -> str:
|
| 63 |
+
\"\"\"
|
| 64 |
+
Moves the mouse to selected coordinates, then uses the scroll button: this could scroll the page or zoom, depending on the app. DO NOT use scroll to move through linux desktop menus.
|
| 65 |
+
Args:
|
| 66 |
+
x: The x coordinate (horizontal position) of the element to scroll/zoom, defaults to None to not focus on specific coordinates
|
| 67 |
+
y: The y coordinate (vertical position) of the element to scroll/zoom, defaults to None to not focus on specific coordinates
|
| 68 |
+
direction: The direction to scroll ("up" or "down"), defaults to "down". For zoom, "up" zooms in, "down" zooms out.
|
| 69 |
+
amount: The amount to scroll. A good amount is 1 or 2.
|
| 70 |
+
\"\"\"
|
| 71 |
+
|
| 72 |
+
def wait(seconds: float) -> str:
|
| 73 |
+
\"\"\"
|
| 74 |
+
Waits for the specified number of seconds. Very useful in case the prior order is still executing (for example starting very heavy applications like browsers or office apps)
|
| 75 |
+
Args:
|
| 76 |
+
seconds: Number of seconds to wait, generally 2 is enough.
|
| 77 |
+
\"\"\"
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
MOBILE_ACTIONS = """
|
| 81 |
+
def navigate_back() -> str:
|
| 82 |
+
\"\"\"
|
| 83 |
+
Return to home page
|
| 84 |
+
\"\"\"
|
| 85 |
+
|
| 86 |
+
def open_app(app_name: str) -> str:
|
| 87 |
+
\"\"\"
|
| 88 |
+
Launches the specified application.
|
| 89 |
+
Args:
|
| 90 |
+
app_name: the name of the application to launch
|
| 91 |
+
\"\"\"
|
| 92 |
+
|
| 93 |
+
def swipe(from_coord: list[str], to_coord: list[str]) -> str:
|
| 94 |
+
\"\"\"
|
| 95 |
+
swipe from 'from_coord' to 'to_coord'
|
| 96 |
+
Args:
|
| 97 |
+
from_coord: origin coordinates
|
| 98 |
+
to_coord: end coordinates
|
| 99 |
+
\"\"\"
|
| 100 |
+
|
| 101 |
+
def long_press(x: int, y: int) -> str:
|
| 102 |
+
\"\"\"
|
| 103 |
+
Performs a long-press at the specified coordinates
|
| 104 |
+
Args:
|
| 105 |
+
x: The x coordinate (horizontal position)
|
| 106 |
+
y: The y coordinate (vertical position)
|
| 107 |
+
\"\"\"
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
OS_SYSTEM_PROMPT = f"""You are a helpful GUI agent. You’ll be given a task and a screenshot of the screen. Complete the task using Python function calls.
|
| 111 |
+
|
| 112 |
+
For each step:
|
| 113 |
+
• First, <think></think> to express the thought process guiding your next action and the reasoning behind it.
|
| 114 |
+
• Then, use <code></code> to perform the action. it will be executed in a stateful environment.
|
| 115 |
+
|
| 116 |
+
The following functions are exposed to the Python interpreter:
|
| 117 |
+
<code>
|
| 118 |
+
{OS_ACTIONS}
|
| 119 |
+
</code>
|
| 120 |
+
|
| 121 |
+
The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
MOBILE_SYSTEM_PROMPT = f"""You are a helpful GUI agent. You’ll be given a task and a screenshot of the screen. Complete the task using Python function calls.
|
| 125 |
+
|
| 126 |
+
For each step:
|
| 127 |
+
• First, <think></think> to express the thought process guiding your next action and the reasoning behind it.
|
| 128 |
+
• Then, use <code></code> to perform the action. it will be executed in a stateful environment.
|
| 129 |
+
|
| 130 |
+
The following functions are exposed to the Python interpreter:
|
| 131 |
+
<code>
|
| 132 |
+
|
| 133 |
+
# OS ACTIONS
|
| 134 |
+
|
| 135 |
+
{OS_ACTIONS}
|
| 136 |
+
|
| 137 |
+
# MOBILE ACTIONS
|
| 138 |
+
|
| 139 |
+
{MOBILE_ACTIONS}
|
| 140 |
+
</code>
|
| 141 |
+
|
| 142 |
+
The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
|
| 143 |
+
"""
|