Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,7 +17,33 @@ def fetch_astrology_data(endpoint, dob, tob, lat, lon, tz):
|
|
| 17 |
else:
|
| 18 |
return f"Error fetching data: {response.status_code} - {response.text}"
|
| 19 |
|
| 20 |
-
# Function to check
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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):
|
|
@@ -39,43 +65,28 @@ def check_dasha(dasha_type, name, dob, tob, lat, lon, tz):
|
|
| 39 |
|
| 40 |
## Mahadasha Sequence:
|
| 41 |
Here is the order of your Mahadasha periods:
|
| 42 |
-
|
| 43 |
-
| **Period** | **Planet** |
|
| 44 |
-
|--------------|---------------|
|
| 45 |
"""
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
readable_response = f"""
|
| 67 |
-
### {dosha_type.replace('-', ' ').title()} Analysis for {name}
|
| 68 |
-
|
| 69 |
-
**Dosha Presence:** {'Yes' if dosha_present else 'No'}
|
| 70 |
-
**Score:** {score}%
|
| 71 |
-
|
| 72 |
-
**Detailed Analysis:**
|
| 73 |
-
- **Moon Influence:** {factors.get('moon', 'Not mentioned')}
|
| 74 |
-
- **Saturn Influence:** {factors.get('saturn', 'Not mentioned')}
|
| 75 |
-
- **Rahu Influence:** {factors.get('rahu', 'Not mentioned')}
|
| 76 |
|
| 77 |
-
**Astrological Suggestion:** {bot_response}
|
| 78 |
-
"""
|
| 79 |
return gr.Markdown(readable_response)
|
| 80 |
|
| 81 |
# Gradio UI with improvements
|
|
@@ -88,8 +99,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 88 |
tob = gr.Textbox(label="Time of Birth (HH:MM)", placeholder="11:40")
|
| 89 |
|
| 90 |
with gr.Row():
|
| 91 |
-
lat = gr.Number(label="Latitude", value=
|
| 92 |
-
lon = gr.Number(label="Longitude", value=
|
| 93 |
tz = gr.Number(label="Timezone (e.g., 5.5 for India)", value=5.5)
|
| 94 |
|
| 95 |
result = gr.Markdown()
|
|
@@ -113,4 +124,5 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 113 |
create_button("Char Dasha Current", "char-dasha-current", check_dasha)
|
| 114 |
|
| 115 |
gr.Markdown("### 🔍 Enter your details above and click the relevant button to analyze your astrology report!")
|
|
|
|
| 116 |
demo.launch()
|
|
|
|
| 17 |
else:
|
| 18 |
return f"Error fetching data: {response.status_code} - {response.text}"
|
| 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 gr.Markdown(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 gr.Markdown(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):
|
|
|
|
| 65 |
|
| 66 |
## Mahadasha Sequence:
|
| 67 |
Here is the order of your Mahadasha periods:
|
|
|
|
|
|
|
|
|
|
| 68 |
"""
|
| 69 |
|
| 70 |
+
if len(mahadasha) == 0 or len(mahadasha_order) == 0:
|
| 71 |
+
readable_response += "**No Mahadasha data available.**"
|
| 72 |
+
else:
|
| 73 |
+
table = "| **Period** | **Planet** |\n|--------------|---------------|\n"
|
| 74 |
+
for i in range(len(mahadasha)):
|
| 75 |
+
if i < len(mahadasha_order):
|
| 76 |
+
period = mahadasha_order[i]
|
| 77 |
+
planet = mahadasha[i]
|
| 78 |
+
table += f"| {period} | {planet} |\n"
|
| 79 |
+
|
| 80 |
+
readable_response += table
|
| 81 |
+
|
| 82 |
+
if not mahadasha or not mahadasha_order:
|
| 83 |
+
readable_response += "\n## Astrological Insights: Data not available for the current period."
|
| 84 |
+
else:
|
| 85 |
+
readable_response += """
|
| 86 |
+
## Astrological Insights:
|
| 87 |
+
Based on your Mahadasha periods, you can predict the influences of each planet during your life.
|
| 88 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
|
|
|
|
|
|
| 90 |
return gr.Markdown(readable_response)
|
| 91 |
|
| 92 |
# Gradio UI with improvements
|
|
|
|
| 99 |
tob = gr.Textbox(label="Time of Birth (HH:MM)", placeholder="11:40")
|
| 100 |
|
| 101 |
with gr.Row():
|
| 102 |
+
lat = gr.Number(label="Latitude", value=11)
|
| 103 |
+
lon = gr.Number(label="Longitude", value=77)
|
| 104 |
tz = gr.Number(label="Timezone (e.g., 5.5 for India)", value=5.5)
|
| 105 |
|
| 106 |
result = gr.Markdown()
|
|
|
|
| 124 |
create_button("Char Dasha Current", "char-dasha-current", check_dasha)
|
| 125 |
|
| 126 |
gr.Markdown("### 🔍 Enter your details above and click the relevant button to analyze your astrology report!")
|
| 127 |
+
|
| 128 |
demo.launch()
|