arpit13 commited on
Commit
0efe4b7
·
verified ·
1 Parent(s): 47e0838

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -44
app.py CHANGED
@@ -17,54 +17,39 @@ def fetch_astrology_data(endpoint, dob, tob, lat, lon, tz):
17
  else:
18
  return f"Error fetching data: {response.status_code}"
19
 
20
- # Function to check dosha
21
- def check_dosha(dosha_type, name, dob, tob, lat, lon, tz):
22
- response = fetch_astrology_data(f"dosha/{dosha_type}", dob, tob, lat, lon, tz)
23
- if isinstance(response, str):
24
- return response
25
-
26
- factors = response.get("factors", {})
27
- dosha_present = response.get("is_dosha_present", False)
28
- bot_response = response.get("bot_response", "No information available")
29
- score = response.get("score", "N/A")
30
-
31
- readable_response = f"""
32
- ### {dosha_type.replace('-', ' ').title()} Analysis for {name}
33
-
34
- **Dosha Presence:** {'Yes' if dosha_present else 'No'}
35
- **Score:** {score}%
36
-
37
- **Detailed Analysis:**
38
- - **Moon Influence:** {factors.get('moon', 'Not mentioned')}
39
- - **Saturn Influence:** {factors.get('saturn', 'Not mentioned')}
40
- - **Rahu Influence:** {factors.get('rahu', 'Not mentioned')}
41
-
42
- **Astrological Suggestion:** {bot_response}
43
- """
44
- return readable_response
45
-
46
  # Function to check dasha
47
  def check_dasha(dasha_type, name, dob, tob, lat, lon, tz):
48
  response = fetch_astrology_data(f"dashas/{dasha_type}", dob, tob, lat, lon, tz)
49
  if isinstance(response, str):
50
  return response
51
 
52
- # Format the dasha data to make it more readable
53
- analysis = response.get("analysis", [])
54
- period = response.get("period", "N/A")
55
- dasha_details = "\n".join([f"- {item}" for item in analysis])
 
56
 
 
57
  readable_response = f"""
58
  ### {dasha_type.replace('-', ' ').title()} Analysis for {name}
59
 
60
- **Period:** {period}
61
 
62
- **Detailed Dasha Analysis:**
63
- {dasha_details}
64
 
65
- **Astrological Suggestions:**
66
- - Follow the guidance based on your dasha period.
 
 
 
67
  """
 
 
 
 
 
 
 
68
  return readable_response
69
 
70
  # Gradio UI with improvements
@@ -77,22 +62,22 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
77
  tob = gr.Textbox(label="Time of Birth (HH:MM)", placeholder="11:40")
78
 
79
  with gr.Row():
80
- lat = gr.Number(label="Latitude", value=11)
81
- lon = gr.Number(label="Longitude", value=77)
82
  tz = gr.Number(label="Timezone (e.g., 5.5 for India)", value=5.5)
83
 
84
  result = gr.Markdown()
85
 
86
- def create_button(label, dosha_type, fn):
87
- return gr.Button(label, variant="primary").click(fn, inputs=[gr.State(dosha_type), name, dob, tob, lat, lon, tz], outputs=result)
88
 
89
  gr.Markdown("## 🌟 Dosha Analysis")
90
  with gr.Row():
91
- create_button("Mangal Dosh", "mangal-dosh", check_dosha)
92
- create_button("Kaalsarp Dosh", "kaalsarp-dosh", check_dosha)
93
- create_button("Manglik Dosh", "manglik-dosh", check_dosha)
94
- create_button("Pitra Dosh", "pitra-dosh", check_dosha)
95
- create_button("Papasamaya", "papasamaya", check_dosha)
96
 
97
  gr.Markdown("## 🔮 Dasha Analysis")
98
  with gr.Row():
 
17
  else:
18
  return f"Error fetching data: {response.status_code}"
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # Function to check dasha
21
  def check_dasha(dasha_type, name, dob, tob, lat, lon, tz):
22
  response = fetch_astrology_data(f"dashas/{dasha_type}", dob, tob, lat, lon, tz)
23
  if isinstance(response, str):
24
  return response
25
 
26
+ # Extracting Mahadasha and its order details
27
+ mahadasha = response.get("mahadasha", [])
28
+ mahadasha_order = response.get("mahadasha_order", [])
29
+ dasha_start_date = response.get("dasha_start_date", "N/A")
30
+ dasha_remaining_at_birth = response.get("dasha_remaining_at_birth", "N/A")
31
 
32
+ # Format the dasha data to make it more readable
33
  readable_response = f"""
34
  ### {dasha_type.replace('-', ' ').title()} Analysis for {name}
35
 
36
+ **Dasha Start Date:** {dasha_start_date}
37
 
38
+ **Remaining Dasha at Birth:** {dasha_remaining_at_birth}
 
39
 
40
+ ## Mahadasha Sequence:
41
+ Here is the order of your Mahadasha periods:
42
+
43
+ | **Period** | **Planet** |
44
+ |--------------|---------------|
45
  """
46
+
47
+ for i in range(len(mahadasha)):
48
+ if i < len(mahadasha_order):
49
+ readable_response += f"| {mahadasha_order[i]} | {mahadasha[i]} |\n"
50
+
51
+ readable_response += "\n**Astrological Insights:** Based on your Mahadasha periods, you can predict the influences of each planet during your life."
52
+
53
  return readable_response
54
 
55
  # Gradio UI with improvements
 
62
  tob = gr.Textbox(label="Time of Birth (HH:MM)", placeholder="11:40")
63
 
64
  with gr.Row():
65
+ lat = gr.Number(label="Latitude", value=0)
66
+ lon = gr.Number(label="Longitude", value=0)
67
  tz = gr.Number(label="Timezone (e.g., 5.5 for India)", value=5.5)
68
 
69
  result = gr.Markdown()
70
 
71
+ def create_button(label, dasha_type, fn):
72
+ return gr.Button(label, variant="primary").click(fn, inputs=[gr.State(dasha_type), name, dob, tob, lat, lon, tz], outputs=result)
73
 
74
  gr.Markdown("## 🌟 Dosha Analysis")
75
  with gr.Row():
76
+ create_button("Mangal Dosh", "mangal-dosh", check_dasha)
77
+ create_button("Kaalsarp Dosh", "kaalsarp-dosh", check_dasha)
78
+ create_button("Manglik Dosh", "manglik-dosh", check_dasha)
79
+ create_button("Pitra Dosh", "pitra-dosh", check_dasha)
80
+ create_button("Papasamaya", "papasamaya", check_dasha)
81
 
82
  gr.Markdown("## 🔮 Dasha Analysis")
83
  with gr.Row():