Adoption commited on
Commit
06aa744
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -33,6 +33,33 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def fetch_artist_networth(artist_name):
38
+ """
39
+ Fetches the net worth of an artist by scraping search result snippets.
40
+
41
+ Args:
42
+ artist_name (str): Name of the artist (e.g., "Beyoncé")
43
+
44
+ Returns:
45
+ str: Net worth (e.g., "800 million") or a fallback message.
46
+ """
47
+ query = f"artist_name net worth"
48
+ headers = "User-Agent": "Mozilla/5.0"
49
+ res = requests.get("https://www.google.com/search", params="q": query, headers=headers)
50
+ soup = BeautifulSoup(res.text, "html.parser")
51
+
52
+ # Try to find a rich result or snippet line containing "... million/billion"
53
+ snippet = soup.find("div", class_="BNeawe")
54
+ if snippet:
55
+ text = snippet.get_text()
56
+ import re
57
+ match = re.search(r"\$\d+(?:\.\d+)?\s*(?:million|billion)", text, re.IGNORECASE)
58
+ if match:
59
+ return match.group(0)
60
+
61
+ return "Net worth not found 🤷"
62
+
63
 
64
  final_answer = FinalAnswerTool()
65