Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -99,7 +99,7 @@ def save_screenshot(memory_step: ActionStep, agent: CodeAgent) -> Image.Image:
|
|
99 |
# Save new screenshot
|
100 |
png_bytes = driver.get_screenshot_as_png()
|
101 |
image = Image.open(BytesIO(png_bytes))
|
102 |
-
screenshot_dir = os.path.join(tempfile.gettempdir(), "
|
103 |
os.makedirs(screenshot_dir, exist_ok=True)
|
104 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
105 |
screenshot_filename = f"screenshot_step_{current_step}_{timestamp}.png"
|
@@ -169,7 +169,7 @@ def run_agent_chat(user_input: str, history: list):
|
|
169 |
url = user_input.split()[0] if user_input.startswith("http") else next((w for w in user_input.split() if w.startswith("http")), "")
|
170 |
request = user_input.replace(url, "").strip() or "Navigate to the URL and describe the page."
|
171 |
else:
|
172 |
-
url = "https://example.com"
|
173 |
request = user_input
|
174 |
|
175 |
search_request = f"Please go to {url}. {request}"
|
@@ -198,8 +198,8 @@ def run_agent_chat(user_input: str, history: list):
|
|
198 |
except:
|
199 |
logger.warning("Failed to close Chrome driver.")
|
200 |
|
201 |
-
# Launch GradioUI
|
202 |
if __name__ == "__main__":
|
203 |
file_upload_folder = os.path.join(tempfile.gettempdir(), "web_agent_uploads")
|
204 |
os.makedirs(file_upload_folder, exist_ok=True)
|
205 |
-
GradioUI(agent=agent,
|
|
|
99 |
# Save new screenshot
|
100 |
png_bytes = driver.get_screenshot_as_png()
|
101 |
image = Image.open(BytesIO(png_bytes))
|
102 |
+
screenshot_dir = os.path.join(tempfile.gettempdir(), "web_agent_sScreenshots")
|
103 |
os.makedirs(screenshot_dir, exist_ok=True)
|
104 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
105 |
screenshot_filename = f"screenshot_step_{current_step}_{timestamp}.png"
|
|
|
169 |
url = user_input.split()[0] if user_input.startswith("http") else next((w for w in user_input.split() if w.startswith("http")), "")
|
170 |
request = user_input.replace(url, "").strip() or "Navigate to the URL and describe the page."
|
171 |
else:
|
172 |
+
url = "https://example.com" # Default URL if none provided
|
173 |
request = user_input
|
174 |
|
175 |
search_request = f"Please go to {url}. {request}"
|
|
|
198 |
except:
|
199 |
logger.warning("Failed to close Chrome driver.")
|
200 |
|
201 |
+
# Launch GradioUI (Option 1: Preferred)
|
202 |
if __name__ == "__main__":
|
203 |
file_upload_folder = os.path.join(tempfile.gettempdir(), "web_agent_uploads")
|
204 |
os.makedirs(file_upload_folder, exist_ok=True)
|
205 |
+
GradioUI(agent=agent, file_upload_folder=file_upload_folder).launch()
|