krrishk22 commited on
Commit
187f909
·
verified ·
1 Parent(s): 6d40909

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -96,8 +96,8 @@ def get_date_panchang(date: str = None, data_language: str = "EN") -> str:
96
  now = datetime.datetime.strptime(date, "%Y-%m-%d")
97
  except ValueError:
98
  return "❌ Invalid date format. Use YYYY-MM-DD."
99
-
100
- api_date = now.strftime("%d/%m/%y") # Format as DD/MM/YY
101
 
102
  try:
103
  url = (
@@ -106,7 +106,7 @@ def get_date_panchang(date: str = None, data_language: str = "EN") -> str:
106
  )
107
 
108
  headers = {
109
- "Authorization": "anvl_bharat_cal123", # 🔁 Replace with your actual token
110
  "Content-Type": "application/json"
111
  }
112
 
@@ -121,6 +121,9 @@ def get_date_panchang(date: str = None, data_language: str = "EN") -> str:
121
  lines = [f"📅 {data.get('date', api_date)} का पंचांग ({data.get('location', 'Unknown')}):\n"]
122
 
123
  for key, value in data.items():
 
 
 
124
  if isinstance(value, list):
125
  if all(isinstance(item, str) for item in value):
126
  lines.append(f"🔹 {key}: {', '.join(value)}")
@@ -140,6 +143,8 @@ def get_date_panchang(date: str = None, data_language: str = "EN") -> str:
140
  except Exception as e:
141
  return f"❌ Failed to fetch Panchang for {api_date}: {str(e)}"
142
 
 
 
143
  @tool
144
  def get_holidays(year: int = None, date: str = None) -> str:
145
  """Fetches government and popular holidays for a given date or year.
 
96
  now = datetime.datetime.strptime(date, "%Y-%m-%d")
97
  except ValueError:
98
  return "❌ Invalid date format. Use YYYY-MM-DD."
99
+
100
+ api_date = now.strftime("%d/%m/%y") # Format as DD/MM/YY for API
101
 
102
  try:
103
  url = (
 
106
  )
107
 
108
  headers = {
109
+ "Authorization": "anvl_bharat_cal123", # Replace with your actual token
110
  "Content-Type": "application/json"
111
  }
112
 
 
121
  lines = [f"📅 {data.get('date', api_date)} का पंचांग ({data.get('location', 'Unknown')}):\n"]
122
 
123
  for key, value in data.items():
124
+ if key in ["date", "location", "app_language", "data_language", "universalDate"]:
125
+ continue # Skip metadata
126
+
127
  if isinstance(value, list):
128
  if all(isinstance(item, str) for item in value):
129
  lines.append(f"🔹 {key}: {', '.join(value)}")
 
143
  except Exception as e:
144
  return f"❌ Failed to fetch Panchang for {api_date}: {str(e)}"
145
 
146
+
147
+
148
  @tool
149
  def get_holidays(year: int = None, date: str = None) -> str:
150
  """Fetches government and popular holidays for a given date or year.