update action history prompt (#1932)
This commit is contained in:
@@ -1542,29 +1542,28 @@ class ForgeAgent:
|
|||||||
actions_and_results.extend(window_step.output.actions_and_results)
|
actions_and_results.extend(window_step.output.actions_and_results)
|
||||||
|
|
||||||
# exclude successful action from history
|
# exclude successful action from history
|
||||||
return json.dumps(
|
action_history = [
|
||||||
[
|
{
|
||||||
{
|
"action": action.model_dump(
|
||||||
"action": action.model_dump(
|
exclude_none=True,
|
||||||
|
include={"action_type", "element_id", "status", "reasoning", "option", "download"},
|
||||||
|
),
|
||||||
|
"results": [
|
||||||
|
result.model_dump(
|
||||||
exclude_none=True,
|
exclude_none=True,
|
||||||
include={"action_type", "element_id", "status", "reasoning", "option", "download"},
|
include={
|
||||||
),
|
"success",
|
||||||
"results": [
|
"exception_type",
|
||||||
result.model_dump(
|
"exception_message",
|
||||||
exclude_none=True,
|
},
|
||||||
include={
|
)
|
||||||
"success",
|
for result in results
|
||||||
"exception_type",
|
],
|
||||||
"exception_message",
|
}
|
||||||
},
|
for action, results in actions_and_results
|
||||||
)
|
if len(results) > 0
|
||||||
for result in results
|
]
|
||||||
],
|
return json.dumps(action_history) if action_history else ""
|
||||||
}
|
|
||||||
for action, results in actions_and_results
|
|
||||||
if len(results) > 0
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
async def get_extracted_information_for_task(self, task: Task) -> dict[str, Any] | list | str | None:
|
async def get_extracted_information_for_task(self, task: Task) -> dict[str, Any] | list | str | None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -9,11 +9,6 @@ Make sure to ONLY return the JSON object in this format with no additional text
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Elements on the page:
|
|
||||||
```
|
|
||||||
{{ elements }}
|
|
||||||
```
|
|
||||||
|
|
||||||
User Goal:
|
User Goal:
|
||||||
```
|
```
|
||||||
{{ navigation_goal }}
|
{{ navigation_goal }}
|
||||||
@@ -28,3 +23,8 @@ Complete Criterion:
|
|||||||
```
|
```
|
||||||
{{ complete_criterion }}
|
{{ complete_criterion }}
|
||||||
```{% endif %}
|
```{% endif %}
|
||||||
|
|
||||||
|
Elements on the page:
|
||||||
|
```
|
||||||
|
{{ elements }}
|
||||||
|
```
|
||||||
@@ -42,13 +42,12 @@ Reply in JSON format with the following keys:
|
|||||||
}
|
}
|
||||||
{% if action_history %}
|
{% if action_history %}
|
||||||
Consider the action history from the last step and the screenshot together, if actions from the last step don't yield positive impact, try other actions or other action combinations.
|
Consider the action history from the last step and the screenshot together, if actions from the last step don't yield positive impact, try other actions or other action combinations.
|
||||||
{% endif %}
|
|
||||||
Clickable elements from `{{ current_url }}`:
|
|
||||||
```
|
|
||||||
{{ elements }}
|
|
||||||
```
|
|
||||||
|
|
||||||
The URL of the page you're on right now is `{{ current_url }}`.
|
Action history from previous steps: (note: even if the action history suggests goal is achieved, check the screenshot and the DOM elements to make sure the goal is achieved)
|
||||||
|
```
|
||||||
|
{{ action_history }}
|
||||||
|
```
|
||||||
|
{% endif %}
|
||||||
{% if complete_criterion %}
|
{% if complete_criterion %}
|
||||||
Complete criterion:
|
Complete criterion:
|
||||||
```
|
```
|
||||||
@@ -74,10 +73,14 @@ User details:
|
|||||||
```
|
```
|
||||||
{{ navigation_payload_str }}
|
{{ navigation_payload_str }}
|
||||||
```
|
```
|
||||||
{% if action_history %}
|
|
||||||
Action results from previous steps: (note: even if the action history suggests goal is achieved, check the screenshot and the DOM elements to make sure the goal is achieved)
|
Clickable elements from `{{ current_url }}`:
|
||||||
{{ action_history }}
|
```
|
||||||
{% endif %}
|
{{ elements }}
|
||||||
|
```
|
||||||
|
|
||||||
|
The URL of the page you're on right now is `{{ current_url }}`.
|
||||||
|
|
||||||
Current datetime, ISO format:
|
Current datetime, ISO format:
|
||||||
```
|
```
|
||||||
{{ local_datetime }}
|
{{ local_datetime }}
|
||||||
|
|||||||
@@ -19,13 +19,6 @@ Reply in JSON format with the following keys:
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
The URL of the page you're on right now is `{{ current_url }}`.
|
|
||||||
|
|
||||||
HTML elements from `{{ current_url }}`:
|
|
||||||
```
|
|
||||||
{{ elements }}
|
|
||||||
```
|
|
||||||
|
|
||||||
User instruction (user's intention or self questioning to help figure out what to click):
|
User instruction (user's intention or self questioning to help figure out what to click):
|
||||||
```
|
```
|
||||||
{{ navigation_goal }}
|
{{ navigation_goal }}
|
||||||
@@ -41,6 +34,13 @@ Context of the big goal user wants to achieve:
|
|||||||
{{ user_context }}
|
{{ user_context }}
|
||||||
```{% endif %}
|
```{% endif %}
|
||||||
|
|
||||||
|
The URL of the page you're on right now is `{{ current_url }}`.
|
||||||
|
|
||||||
|
HTML elements from `{{ current_url }}`:
|
||||||
|
```
|
||||||
|
{{ elements }}
|
||||||
|
```
|
||||||
|
|
||||||
Current datetime, ISO format:
|
Current datetime, ISO format:
|
||||||
```
|
```
|
||||||
{{ local_datetime }}
|
{{ local_datetime }}
|
||||||
|
|||||||
@@ -20,13 +20,6 @@ Reply in JSON format with the following keys:
|
|||||||
"need_verification_code": bool, // Whether a verification code is needed to proceed. True only if the code is available to user. If the code is not sent, return false {% endif %}
|
"need_verification_code": bool, // Whether a verification code is needed to proceed. True only if the code is available to user. If the code is not sent, return false {% endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
The URL of the page you're on right now is `{{ current_url }}`.
|
|
||||||
|
|
||||||
HTML elements from `{{ current_url }}`:
|
|
||||||
```
|
|
||||||
{{ elements }}
|
|
||||||
```
|
|
||||||
|
|
||||||
User instruction:
|
User instruction:
|
||||||
```
|
```
|
||||||
{{ navigation_goal }}
|
{{ navigation_goal }}
|
||||||
@@ -37,6 +30,13 @@ User details:
|
|||||||
{{ navigation_payload_str }}
|
{{ navigation_payload_str }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The URL of the page you're on right now is `{{ current_url }}`.
|
||||||
|
|
||||||
|
HTML elements from `{{ current_url }}`:
|
||||||
|
```
|
||||||
|
{{ elements }}
|
||||||
|
```
|
||||||
|
|
||||||
Current datetime, ISO format:
|
Current datetime, ISO format:
|
||||||
```
|
```
|
||||||
{{ local_datetime }}
|
{{ local_datetime }}
|
||||||
|
|||||||
@@ -22,13 +22,6 @@ Reply in JSON format with the following keys:
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
The URL of the page you're on right now is `{{ current_url }}`.
|
|
||||||
|
|
||||||
HTML elements from `{{ current_url }}`:
|
|
||||||
```
|
|
||||||
{{ elements }}
|
|
||||||
```
|
|
||||||
|
|
||||||
User instruction:
|
User instruction:
|
||||||
```
|
```
|
||||||
{{ navigation_goal }}
|
{{ navigation_goal }}
|
||||||
@@ -39,6 +32,13 @@ User details:
|
|||||||
{{ navigation_payload_str }}
|
{{ navigation_payload_str }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The URL of the page you're on right now is `{{ current_url }}`.
|
||||||
|
|
||||||
|
HTML elements from `{{ current_url }}`:
|
||||||
|
```
|
||||||
|
{{ elements }}
|
||||||
|
```
|
||||||
|
|
||||||
Current datetime, ISO format:
|
Current datetime, ISO format:
|
||||||
```
|
```
|
||||||
{{ local_datetime }}
|
{{ local_datetime }}
|
||||||
|
|||||||
@@ -18,13 +18,6 @@ Reply in JSON format with the following keys:
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
The URL of the page you're on right now is `{{ current_url }}`.
|
|
||||||
|
|
||||||
HTML elements from `{{ current_url }}`:
|
|
||||||
```
|
|
||||||
{{ elements }}
|
|
||||||
```
|
|
||||||
|
|
||||||
User instruction:
|
User instruction:
|
||||||
```
|
```
|
||||||
{{ navigation_goal }}
|
{{ navigation_goal }}
|
||||||
@@ -35,6 +28,13 @@ User details:
|
|||||||
{{ navigation_payload_str }}
|
{{ navigation_payload_str }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The URL of the page you're on right now is `{{ current_url }}`.
|
||||||
|
|
||||||
|
HTML elements from `{{ current_url }}`:
|
||||||
|
```
|
||||||
|
{{ elements }}
|
||||||
|
```
|
||||||
|
|
||||||
Current datetime, ISO format:
|
Current datetime, ISO format:
|
||||||
```
|
```
|
||||||
{{ local_datetime }}
|
{{ local_datetime }}
|
||||||
|
|||||||
Reference in New Issue
Block a user