mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-02 10:41:04 +00:00
Pass current url to extract-action prompt (#184)
This commit is contained in:
parent
7b1c1d5a02
commit
cc87844825
2 changed files with 11 additions and 4 deletions
|
@ -608,12 +608,17 @@ class ForgeAgent(Agent):
|
||||||
action_results_str = json.dumps([action_result.model_dump() for action_result in action_results])
|
action_results_str = json.dumps([action_result.model_dump() for action_result in action_results])
|
||||||
# Generate the extract action prompt
|
# Generate the extract action prompt
|
||||||
navigation_goal = task.navigation_goal
|
navigation_goal = task.navigation_goal
|
||||||
|
starting_url = task.url
|
||||||
|
current_url = (
|
||||||
|
await browser_state.page.evaluate("() => document.location.href") if browser_state.page else starting_url
|
||||||
|
)
|
||||||
extract_action_prompt = prompt_engine.load_prompt(
|
extract_action_prompt = prompt_engine.load_prompt(
|
||||||
"extract-action",
|
"extract-action",
|
||||||
navigation_goal=navigation_goal,
|
navigation_goal=navigation_goal,
|
||||||
navigation_payload_str=json.dumps(task.navigation_payload),
|
navigation_payload_str=json.dumps(task.navigation_payload),
|
||||||
url=task.url,
|
starting_url=starting_url,
|
||||||
elements=scraped_page.element_tree_trimmed, # scraped_page.element_tree,
|
current_url=current_url,
|
||||||
|
elements=scraped_page.element_tree_trimmed,
|
||||||
data_extraction_goal=task.data_extraction_goal,
|
data_extraction_goal=task.data_extraction_goal,
|
||||||
action_history=action_results_str,
|
action_history=action_results_str,
|
||||||
error_code_mapping_str=json.dumps(task.error_code_mapping) if task.error_code_mapping else None,
|
error_code_mapping_str=json.dumps(task.error_code_mapping) if task.error_code_mapping else None,
|
||||||
|
|
|
@ -6,7 +6,7 @@ Each element is tagged with an ID.
|
||||||
If you see any information in red in the page screenshot, this means a condition wasn't satisfied. prioritize actions with the red information.
|
If you see any information in red in the page screenshot, this means a condition wasn't satisfied. prioritize actions with the red information.
|
||||||
If you see a popup in the page screenshot, prioritize actions on the popup.
|
If you see a popup in the page screenshot, prioritize actions on the popup.
|
||||||
|
|
||||||
{% if "lever" in url %}
|
{% if "lever" in starting_url %}
|
||||||
DO NOT UPDATE ANY LOCATION FIELDS
|
DO NOT UPDATE ANY LOCATION FIELDS
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -41,11 +41,13 @@ Reply in JSON format with the following keys:
|
||||||
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 %}
|
{% endif %}
|
||||||
|
|
||||||
Clickable elements from `{{ url }}`:
|
Clickable elements from `{{ current_url }}`:
|
||||||
```
|
```
|
||||||
{{ elements }}
|
{{ elements }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The URL of the page you're on right now is `{{ current_url }}`.
|
||||||
|
|
||||||
User goal:
|
User goal:
|
||||||
```
|
```
|
||||||
{{ navigation_goal }}
|
{{ navigation_goal }}
|
||||||
|
|
Loading…
Add table
Reference in a new issue