prithivMLmods commited on
Commit
95cc485
·
verified ·
1 Parent(s): d849e24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -400,12 +400,16 @@ class SeleniumVisionAgent(CodeAgent):
400
  # Initialize
401
  print(f"Browser size: {self.sandbox.width}x{self.sandbox.height}")
402
  os.makedirs(self.data_dir, exist_ok=True)
 
 
 
403
 
404
  super().__init__(
405
- tools=[],
406
  model=model,
407
  max_steps=max_steps,
408
  verbosity_level=verbosity_level,
 
409
  **kwargs,
410
  )
411
 
@@ -413,11 +417,9 @@ class SeleniumVisionAgent(CodeAgent):
413
  "<<resolution_x>>", str(self.sandbox.width)
414
  ).replace("<<resolution_y>>", str(self.sandbox.height))
415
 
416
- self.register_tools()
417
- self.step_callbacks.append(self.take_screenshot_callback)
418
-
419
- def register_tools(self):
420
-
421
  @tool
422
  def click(x: int, y: int) -> str:
423
  """
@@ -534,16 +536,7 @@ class SeleniumVisionAgent(CodeAgent):
534
  self.sandbox.driver.back()
535
  return "Went back one page"
536
 
537
- self.tools["click"] = click
538
- self.tools["right_click"] = right_click
539
- self.tools["double_click"] = double_click
540
- self.tools["type_text"] = type_text
541
- self.tools["press_key"] = press_key
542
- self.tools["drag_and_drop"] = drag_and_drop
543
- self.tools["scroll"] = scroll
544
- self.tools["wait"] = wait
545
- self.tools["open_url"] = open_url
546
- self.tools["go_back"] = go_back
547
 
548
 
549
  def take_screenshot_callback(self, memory_step: ActionStep, agent=None) -> None:
 
400
  # Initialize
401
  print(f"Browser size: {self.sandbox.width}x{self.sandbox.height}")
402
  os.makedirs(self.data_dir, exist_ok=True)
403
+
404
+ # Build tools list
405
+ tools_list = self.build_tools()
406
 
407
  super().__init__(
408
+ tools=tools_list,
409
  model=model,
410
  max_steps=max_steps,
411
  verbosity_level=verbosity_level,
412
+ step_callbacks=[self.take_screenshot_callback],
413
  **kwargs,
414
  )
415
 
 
417
  "<<resolution_x>>", str(self.sandbox.width)
418
  ).replace("<<resolution_y>>", str(self.sandbox.height))
419
 
420
+ def build_tools(self):
421
+ """Define and return the list of tools for this agent"""
422
+
 
 
423
  @tool
424
  def click(x: int, y: int) -> str:
425
  """
 
536
  self.sandbox.driver.back()
537
  return "Went back one page"
538
 
539
+ return [click, right_click, double_click, type_text, press_key, drag_and_drop, scroll, wait, open_url, go_back]
 
 
 
 
 
 
 
 
 
540
 
541
 
542
  def take_screenshot_callback(self, memory_step: ActionStep, agent=None) -> None: