Spaces:
Configuration error
Configuration error
oremaz commited on
Commit ·
2d8a87a
1
Parent(s): f39446f
Update agent2.py
Browse files143 unmodified lines144145146147148149150151152153154155156157158159160161162163164165166167168169170171172143 unmodified linesreturn f"Error getting page text: {e}"def save_screenshot_callback(memory_step: ActionStep, agent: CodeAgent) -> None:"""Save screenshots for web browser automation"""try:sleep(1.0)driver = helium.get_driver()if driver is not None:# Clean up old screenshotsfor previous_memory_step in agent.memory.steps:if isinstance(previous_memory_step, ActionStep) and previous_memory_step.step_number <= memory_step.step_number - 2:previous_memory_step.observations_images = Nonepng_bytes = driver.get_screenshot_as_png()image = Image.open(BytesIO(png_bytes))memory_step.observations_images = [image.copy()]# Update observations with current URLurl_info = f"Current url: {driver.current_url}"memory_step.observations = (url_info if memory_step.observations is Noneelse memory_step.observations + "\n" + url_info)except Exception as e:print(f"Error in screenshot callback: {e}")class GAIAAgent:143 unmodified lines144145146147148149150151152153154155156157158159160161162163164165166167168169170171172143 unmodified linesreturn f"Error getting page text: {e}"def save_screenshot_callback(memory_step: ActionStep, agent: CodeAgent) -> None:"""Save screenshots for web browser automation"""try:sleep(1.0)driver = helium.get_driver()if driver is not None:# Clean up old screenshotsfor previous_memory_step in agent.memory.steps:if isinstance(previous_memory_step, ActionStep) and previous_memory_step.step_number <= memory_step.step_number - 2:previous_memory_step.observations_images = Nonepng_bytes = driver.get_screenshot_as_png()image = Image.open(BytesIO(png_bytes))memory_step.observations_images = [image.copy()]# Update observations with current URLurl_info = f"Current url: {driver.current_url}"memory_step.observations = (url_info if memory_step.observations is Noneelse memory_step.observations + "\n" + url_info)except Exception as e:print(f"Error in screenshot callback: {e}")class GAIAAgent:
agent2.py+23-23