arpit13 commited on
Commit
838eb4f
·
verified ·
1 Parent(s): d72b485

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -73,10 +73,14 @@ def check_dasha(dasha_type, name, dob, tob, lat, lon, tz):
73
  # Function to check Extended Horoscope
74
  def check_extended_horoscope(endpoint, name, dob, tob, lat, lon, tz):
75
  response = fetch_astrology_data(f"extended-horoscope/{endpoint}", dob, tob, lat, lon, tz)
76
- if not isinstance(response, dict) or "status" not in response or "response" not in response:
77
- return gr.Markdown("Invalid response format.")
 
 
78
 
79
  response_data = response.get("response", {})
 
 
80
  readable_response = f"""
81
  ### {endpoint.replace('-', ' ').title()} Analysis for {name}
82
 
@@ -84,21 +88,22 @@ def check_extended_horoscope(endpoint, name, dob, tob, lat, lon, tz):
84
  """
85
 
86
  for key, value in response_data.items():
87
- if key == "bot_response":
88
  continue
89
  readable_response += f"\n- **{key.replace('_', ' ').title()}**: "
 
90
  if isinstance(value, dict):
91
  for sub_key, sub_value in value.items():
92
  readable_response += f"\n - {sub_key.replace('_', ' ').title()}: {sub_value}"
93
  elif isinstance(value, list):
94
- for item in value:
95
- readable_response += f"\n - {item}"
96
  else:
97
  readable_response += f"{value}"
98
 
99
  return gr.Markdown(readable_response)
100
 
101
 
 
102
  # Gradio UI with new buttons for extended horoscope
103
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
104
  gr.Markdown("# 🪐 Astrology Checker - Find Your Dosha, Dasha, Moon Sign, Sun Sign, Ascendant, Sade Sati, Kundli & Shad Bala 🪐")
 
73
  # Function to check Extended Horoscope
74
  def check_extended_horoscope(endpoint, name, dob, tob, lat, lon, tz):
75
  response = fetch_astrology_data(f"extended-horoscope/{endpoint}", dob, tob, lat, lon, tz)
76
+
77
+ # Ensure response is a valid dictionary
78
+ if not isinstance(response, dict) or "response" not in response:
79
+ return gr.Markdown("Invalid response format or missing data.")
80
 
81
  response_data = response.get("response", {})
82
+
83
+ # Start formatting the response
84
  readable_response = f"""
85
  ### {endpoint.replace('-', ' ').title()} Analysis for {name}
86
 
 
88
  """
89
 
90
  for key, value in response_data.items():
91
+ if key == "bot_response": # Skip bot response
92
  continue
93
  readable_response += f"\n- **{key.replace('_', ' ').title()}**: "
94
+
95
  if isinstance(value, dict):
96
  for sub_key, sub_value in value.items():
97
  readable_response += f"\n - {sub_key.replace('_', ' ').title()}: {sub_value}"
98
  elif isinstance(value, list):
99
+ readable_response += "".join(f"\n - {item}" for item in value)
 
100
  else:
101
  readable_response += f"{value}"
102
 
103
  return gr.Markdown(readable_response)
104
 
105
 
106
+
107
  # Gradio UI with new buttons for extended horoscope
108
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
109
  gr.Markdown("# 🪐 Astrology Checker - Find Your Dosha, Dasha, Moon Sign, Sun Sign, Ascendant, Sade Sati, Kundli & Shad Bala 🪐")