Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,32 +44,40 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
44 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
45 |
|
46 |
@tool
|
47 |
-
def get_horoscope(sign: str, date: str = None, language: str =
|
48 |
"""Fetches the horoscope for a given zodiac sign and date.
|
49 |
-
|
|
|
50 |
Args:
|
51 |
sign: Zodiac sign (e.g., Aries, Taurus, Gemini)
|
52 |
date: Date in any format (optional)
|
|
|
53 |
"""
|
54 |
-
date = parse_date(date)
|
55 |
-
# Placeholder logic
|
56 |
-
if not date:
|
57 |
-
date = datetime.now().strftime("%Y-%m-%d")
|
58 |
-
|
59 |
-
url = "https://api.exaweb.in:3004/api/rashi"
|
60 |
try:
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
response.raise_for_status()
|
63 |
data = response.json()
|
64 |
|
65 |
-
#
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
68 |
|
69 |
-
return f"
|
70 |
|
71 |
except Exception as e:
|
72 |
-
return f"
|
73 |
|
74 |
@tool
|
75 |
def get_date_panchang(date: str = None) -> str:
|
|
|
44 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
45 |
|
46 |
@tool
|
47 |
+
def get_horoscope(sign: str, date: str = None, language: str = "EN") -> str:
|
48 |
"""Fetches the horoscope for a given zodiac sign and date.
|
49 |
+
Uses the ExaWeb API. Defaults to today if no date is provided.
|
50 |
+
|
51 |
Args:
|
52 |
sign: Zodiac sign (e.g., Aries, Taurus, Gemini)
|
53 |
date: Date in any format (optional)
|
54 |
+
language: Language code ('EN' or 'HI')
|
55 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
try:
|
57 |
+
# Parse or use today's date
|
58 |
+
if date:
|
59 |
+
date_obj = parse_date(date)
|
60 |
+
else:
|
61 |
+
date_obj = datetime.now()
|
62 |
+
formatted_date = date_obj.strftime("%d-%m-%Y")
|
63 |
+
|
64 |
+
# API call
|
65 |
+
url = "https://api.exaweb.in:3004/api/rashi/getForAllLangs"
|
66 |
+
response = requests.get(url, params={"day": formatted_date, "language": language})
|
67 |
response.raise_for_status()
|
68 |
data = response.json()
|
69 |
|
70 |
+
# Find horoscope for the given sign
|
71 |
+
sign_upper = sign.upper()
|
72 |
+
for item in data.get("data", []):
|
73 |
+
if item.get("sign", "").upper() == sign_upper:
|
74 |
+
prediction = item.get("prediction", "No prediction found.")
|
75 |
+
return f"Horoscope for {sign.capitalize()} on {formatted_date}:\n{prediction}"
|
76 |
|
77 |
+
return f"No horoscope found for sign: {sign}"
|
78 |
|
79 |
except Exception as e:
|
80 |
+
return f"Error fetching horoscope: {str(e)}"
|
81 |
|
82 |
@tool
|
83 |
def get_date_panchang(date: str = None) -> str:
|