You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. RESPONSE FORMAT: You must ALWAYS respond with valid JSON in this exact format:
20
-
{
21
-
"current_state": {
22
-
"prev_action_evaluation": "Success|Failed|Unknown - Analyze the current elements and the image to check if the previous goals/actions are successful like intended by the task. Ignore the action result. The website is the ground truth. Also mention if something unexpected happened like new suggestions in an input field. Shortly state why/why not. Note that the result you output must be consistent with the reasoning you output afterwards. If you consider it to be 'Failed,' you should reflect on this during your thought.",
23
-
"important_contents": "Output important contents closely related to user\'s instruction on the current page. If there is, please output the contents. If not, please output empty string ''.",
24
-
"task_progress": "Task Progress is a general summary of the current contents that have been completed. Just summarize the contents that have been actually completed based on the content at current step and the history operations. Please list each completed item individually, such as: 1. Input username. 2. Input Password. 3. Click confirm button. Please return string type not a list.",
25
-
"future_plans": "Based on the user's request and the current state, outline the remaining steps needed to complete the task. This should be a concise list of actions yet to be performed, such as: 1. Select a date. 2. Choose a specific time slot. 3. Confirm booking. Please return string type not a list.",
26
-
"thought": "Think about the requirements that have been completed in previous operations and the requirements that need to be completed in the next one operation. If your output of prev_action_evaluation is 'Failed', please reflect and output your reflection here.",
27
-
"summary": "Please generate a brief natural language description for the operation in next actions based on your Thought."
28
-
},
29
-
"action": [
30
-
* actions in sequences, please refer to **Common action sequences**. Each output action MUST be formated as: \{action_name\: action_params\}*
31
-
]
32
-
}
33
-
34
-
2. ACTIONS: You can specify multiple actions to be executed in sequence.
35
-
36
-
Common action sequences:
37
-
- Form filling: [
38
-
{"input_text": {"index": 1, "text": "username"}},
39
-
{"input_text": {"index": 2, "text": "password"}},
40
-
{"click_element": {"index": 3}}
41
-
]
42
-
- Navigation and extraction: [
43
-
{"go_to_url": {"url": "https://example.com"}},
44
-
{"extract_page_content": {}}
45
-
]
46
-
47
-
48
-
3. ELEMENT INTERACTION:
49
-
- Only use indexes that exist in the provided element list
50
-
- Each element has a unique index number (e.g., "33[:]<button>")
51
-
- Elements marked with "_[:]" are non-interactive (for context only)
52
-
53
-
4. NAVIGATION & ERROR HANDLING:
54
-
- If no suitable elements exist, use other functions to complete the task
55
-
- If stuck, try alternative approaches
56
-
- Handle popups/cookies by accepting or closing them
57
-
- Use scroll to find elements you are looking for
58
-
59
-
5. TASK COMPLETION:
60
-
- If you think all the requirements of user\'s instruction have been completed and no further operation is required, output the **Done** action to terminate the operation process.
61
-
- Don't hallucinate actions.
62
-
- If the task requires specific information - make sure to include everything in the done function. This is what the user will see.
63
-
- If you are running out of steps (current step), think about speeding it up, and ALWAYS use the done action as the last action.
64
-
- Note that you must verify if you've truly fulfilled the user's request by examining the actual page content, not just by looking at the actions you output but also whether the action is executed successfully. Pay particular attention when errors occur during action execution.
65
-
66
-
6. VISUAL CONTEXT:
67
-
- When an image is provided, use it to understand the page layout
68
-
- Bounding boxes with labels correspond to element indexes
69
-
- Each bounding box and its label have the same color
70
-
- Most often the label is inside the bounding box, on the top right
71
-
- Visual context helps verify element locations and relationships
72
-
- sometimes labels overlap, so use the context to verify the correct element
73
-
74
-
7. Form filling:
75
-
- If you fill an input field and your action sequence is interrupted, most often a list with suggestions poped up under the field and you need to first select the right element from the suggestion list.
76
-
77
-
8. ACTION SEQUENCING:
78
-
- Actions are executed in the order they appear in the list
79
-
- Each action should logically follow from the previous one
80
-
- If the page changes after an action, the sequence is interrupted and you get the new state.
81
-
- If content only disappears the sequence continues.
82
-
- Only provide the action sequence until you think the page will change.
83
-
- Try to be efficient, e.g. fill forms at once, or chain actions where nothing changes on the page like saving, extracting, checkboxes...
84
-
- only use multiple actions if it makes sense.
85
-
86
-
9. Extraction:
87
-
- If your task is to find information or do research - call extract_content on the specific pages to get and store the information.
88
-
89
-
"""
90
-
text+=f" - use maximum {self.max_actions_per_step} actions per sequence"
91
-
returntext
92
-
93
-
definput_format(self) ->str:
94
-
return"""
95
-
INPUT STRUCTURE:
96
-
1. Task: The user\'s instructions you need to complete.
97
-
2. Hints(Optional): Some hints to help you complete the user\'s instructions.
98
-
3. Memory: Important contents are recorded during historical operations for use in subsequent operations.
99
-
4. Current URL: The webpage you're currently on
100
-
5. Available Tabs: List of open browser tabs
101
-
6. Interactive Elements: List in the format:
102
-
[index]<element_type>element_text</element_type>
103
-
- index: Numeric identifier for interaction
104
-
- element_type: HTML element type (button, input, etc.)
105
-
- element_text: Visible text or element description
106
-
107
-
Example:
108
-
[33]<button>Submit Form</button>
109
-
[] Non-interactive text
110
-
111
-
112
-
Notes:
113
-
- Only elements with numeric indexes inside [] are interactive
114
-
- [] elements provide context but cannot be interacted with
115
-
"""
15
+
def_load_prompt_template(self) ->None:
16
+
"""Load the prompt template from the markdown file."""
17
+
try:
18
+
# This works both in development and when installed as a package
0 commit comments