Skip to content

Commit e1e54a4

Browse files
committed
Merge branch 'dev' of https://github.com/EmergenceAI/Agent-E into dev
2 parents 7cfde2a + 4bf598c commit e1e54a4

6 files changed

+26
-10
lines changed

ae/core/autogen_wrapper.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,16 @@ def trigger_nested_chat(manager: autogen.ConversableAgent):
101101
content:str=manager.last_message()["content"] # type: ignore
102102
content_json=parse_response(content)
103103
next_step = content_json.get('next_step', None)
104+
plan = content_json.get('plan', None)
105+
if plan is not None:
106+
print_message_from_planner("Plan: "+ plan)
104107
print(f"Next Step: {next_step}")
105108
if next_step is None:
106109
print_message_from_planner("Received no response, terminating..") # type: ignore
107110
print("Trigger nested chat returned False")
108111
return False
109112
else:
110-
print_message_from_planner("Next Step: "+ next_step) # type: ignore
113+
print_message_from_planner(next_step) # type: ignore
111114
return True
112115

113116

ae/core/prompts.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@
5656
Your reply: {"terminate":"yes", "final_response": "Here is the Nothing phone 2 price list: <price list>. The cheapest store is <store name> with price <price>."}
5757
5858
Example 2:
59-
Task: Find the cheapest flight from Helsinki to Stockholm on 15 March. Current page: www.skyscanner.com
59+
Task: Find the cheapest premium economy flights from Helsinki to Stockholm on 15 March. Current page: www.skyscanner.com
6060
{"plan":"1. List the interaction options available on skyscanner page relevant for flight reservation along with their default values.
6161
2. Select the journey option to one-way (if not default).
6262
3. Set number of passengers to 1 (if not default).
6363
4. Set the departure date to 15 March 2025 (since 15 March 2024 is already past).
64+
5. Set ticket type to Economy Premium.
6465
5. Set from airport to ""Helsinki".
65-
6. Set destination airport tas Stockhokm
66+
6. Set destination airport to Stockhokm
6667
7. Confirm that current values in the source airport, destination airport and departure date fields are Helsinki, Stockholm and 15 August 2024 respectively.
6768
8. Click on the search button to get the search results.
6869
9. Confirm that you are on the search results page.
6970
10. Extract the price of the cheapest flight from Helsinki to Stokchol from the search results.",
7071
"next_step": "List all interaction options available on this skyscanner page relevant for flight reservation. This could be source airport, destination aiport etc. Also provide the current default values of the fields.",
7172
"terminate":"no"},
73+
Notice above how there is confrimation after each step and how interaction with each element is a seperate step. Follow same pattern.
7274
7375
Remember: you are a very very persistent planner who will try every possible strategy to accomplish the task perfectly.
7476
Revise search query if needed, ask for more information if needed, and always verify the results before terminating the task.""",

ae/core/skills/click_using_selector.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def detect_dom_changes(changes:str): # type: ignore
5252
await asyncio.sleep(0.1) # sleep for 100ms to allow the mutation observer to detect changes
5353
unsubscribe(detect_dom_changes)
5454
await browser_manager.take_screenshots(f"{function_name}_end", page)
55-
await browser_manager.notify_user(result["summary_message"])
55+
#await browser_manager.notify_user(result["summary_message"])
5656

5757
if dom_changes_detected:
5858
return f"Success: {result['summary_message']}.\n As a consequence of this action, new elements have appeared in view: {dom_changes_detected}. This means that the action to click {selector} is not yet executed and needs further interaction. Get all_fields DOM to complete the interaction."

ae/core/skills/enter_text_using_selector.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from ae.utils.logger import logger
1616

1717

18-
1918
@dataclass
2019
class EnterTextEntry:
2120
"""
@@ -127,7 +126,7 @@ def detect_dom_changes(changes:str): # type: ignore
127126

128127
await browser_manager.take_screenshots(f"{function_name}_end", page)
129128

130-
await browser_manager.notify_user(result["summary_message"])
129+
#await browser_manager.notify_user(result["summary_message"])
131130
if dom_changes_detected:
132131
return f"{result['detailed_message']}.\n As a consequence of this action, new elements have appeared in view: {dom_changes_detected}. This means that the action of entering text {text_to_enter} is not yet executed and needs further interaction. Get all_fields DOM to complete the interaction."
133132
return result["detailed_message"]

ae/core/skills/get_dom_with_content_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def get_dom_with_content_type(
7070

7171
elapsed_time = time.time() - start_time
7272
logger.info(f"Get DOM Command executed in {elapsed_time} seconds")
73-
await browser_manager.notify_user(user_success_message)
73+
#await browser_manager.notify_user(user_success_message)
7474
return extracted_data # type: ignore
7575

7676

ae/core/system_orchestrator.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,25 @@ async def process_command(self, command: str):
108108
start_time = time.time()
109109
current_url = await self.browser_manager.get_current_url() if self.browser_manager else None
110110
self.browser_manager.log_user_message(command) # type: ignore
111-
111+
result = None
112112
if self.autogen_wrapper:
113-
await self.autogen_wrapper.process_command(command, current_url)
113+
result=await self.autogen_wrapper.process_command(command, current_url)
114114
end_time = time.time()
115115
elapsed_time = round(end_time - start_time, 2)
116116
logger.info(f"Command \"{command}\" took: {elapsed_time} seconds.")
117-
await self.save_chat_messages()
117+
#await self.save_chat_messages()
118+
print("Checking Result:", result)
119+
if result is not None:
120+
print("Result:", result)
121+
chat_history=result.get("chat_history")
122+
print("Chat history:", chat_history)
123+
last_message = chat_history[-1] if chat_history else None
124+
print("Last message:", last_message)
125+
if last_message and "terminate" in last_message and last_message["terminate"]=="yes":
126+
print("Notifying the user and Terminating the session")
127+
await self.browser_manager.notify_user(last_message)
128+
129+
118130
await self.browser_manager.notify_user(f"Completed ({elapsed_time}s).") # type: ignore
119131
await self.browser_manager.command_completed(command, elapsed_time) # type: ignore
120132
self.is_running = False

0 commit comments

Comments
 (0)