Firoj112 commited on
Commit
29a174e
·
verified ·
1 Parent(s): 5a61b3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -29,6 +29,12 @@ if not gemini_api_key:
29
  # Define tools
30
  @tool
31
  def search_item_ctrl_f(text: str, nth_result: int = 1) -> str:
 
 
 
 
 
 
32
  elements = driver.find_elements(By.XPATH, f"//*[contains(text(), '{text}')]")
33
  if nth_result > len(elements):
34
  raise Exception(f"Match n°{nth_result} not found (only {len(elements)} matches found)")
@@ -40,10 +46,15 @@ def search_item_ctrl_f(text: str, nth_result: int = 1) -> str:
40
 
41
  @tool
42
  def go_back() -> None:
 
43
  driver.back()
44
 
45
  @tool
46
  def close_popups() -> str:
 
 
 
 
47
  webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
48
 
49
  # Initialize Chrome driver
 
29
  # Define tools
30
  @tool
31
  def search_item_ctrl_f(text: str, nth_result: int = 1) -> str:
32
+ """
33
+ Searches for text on the current page via Ctrl + F and jumps to the nth occurrence.
34
+ Args:
35
+ text: The text to search for
36
+ nth_result: Which occurrence to jump to (default: 1)
37
+ """
38
  elements = driver.find_elements(By.XPATH, f"//*[contains(text(), '{text}')]")
39
  if nth_result > len(elements):
40
  raise Exception(f"Match n°{nth_result} not found (only {len(elements)} matches found)")
 
46
 
47
  @tool
48
  def go_back() -> None:
49
+ """Goes back to previous page."""
50
  driver.back()
51
 
52
  @tool
53
  def close_popups() -> str:
54
+ """
55
+ Closes any visible modal or pop-up on the page. Use this to dismiss pop-up windows!
56
+ This does not work on cookie consent banners.
57
+ """
58
  webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
59
 
60
  # Initialize Chrome driver