J3 commited on
Commit
12caf28
·
verified ·
1 Parent(s): ae7a494

add Horoscope tool

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -18,6 +18,33 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def get_tomorrows_prediction(zodiac_sign: str) -> str:
23
+ """A tool that fetches tomorrows horoscope prediction given a zodiac sign.
24
+ Args:
25
+ zodiac_sign: A string representing a zodiac sign (e.g., 'leo').
26
+ """
27
+ try:
28
+ #importing necessary liabraries
29
+ import requests
30
+ from bs4 import BeautifulSoup
31
+
32
+ # Making a GET request
33
+ r = requests.get(f'https://astrotalk.com/horoscope/tomorrow-horoscope/{zodiac_sign}')
34
+
35
+ # Parsing the HTML
36
+ soup = BeautifulSoup(r.content, 'html.parser')
37
+ s = soup.find('div', class_='parah_aries_horocope')
38
+ content = soup.find_all('p')
39
+
40
+ # concatenating a list of strings into a single string and removing tags:
41
+ sentence = ' '.join(content[:7]).replace('<p>','').replace('</p>','')
42
+
43
+ return sentence
44
+
45
+ except Exception as e:
46
+ return f"Error fetching the horoscope."
47
+
48
  @tool
49
  def get_current_time_in_timezone(timezone: str) -> str:
50
  """A tool that fetches the current local time in a specified timezone.