Firoj112 commited on
Commit
5be8e67
·
verified ·
1 Parent(s): 10e7d79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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(), "web_agent_screenshots")
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 with explicit file_upload_folder
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, chat_function=run_agent_chat, file_upload_folder=file_upload_folder).launch()
 
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()