Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# API endpoint URL for the Horoscope API
|
| 5 |
+
# API_URL = "https://ai-research.quarkgen.ai/templedekho/v1/horoscope"
|
| 6 |
+
API_URL = "https://ai-research.quarkgen.ai/templedekho/v1/numerology"
|
| 7 |
+
|
| 8 |
+
def get_horoscope_response(name, year, month, day, hour, minutes, city, nation, question):
|
| 9 |
+
"""
|
| 10 |
+
Send a POST request to the horoscope API with the user-provided parameters.
|
| 11 |
+
"""
|
| 12 |
+
# Prepare the input payload
|
| 13 |
+
payload = {
|
| 14 |
+
"name": name,
|
| 15 |
+
"year": int(year),
|
| 16 |
+
"month": int(month),
|
| 17 |
+
"day": int(day),
|
| 18 |
+
"hour": int(hour),
|
| 19 |
+
"minutes": int(minutes),
|
| 20 |
+
"city": city,
|
| 21 |
+
"nation": nation,
|
| 22 |
+
"question": question
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
response = requests.post(API_URL, json=payload)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# Check if there was an error in the API response
|
| 29 |
+
if response.status_code == 200:
|
| 30 |
+
response_data = response.text
|
| 31 |
+
# return response_data
|
| 32 |
+
return response_data
|
| 33 |
+
|
| 34 |
+
else:
|
| 35 |
+
return "Sorry, there was an error with your request."
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
# Define the Gradio interface
|
| 39 |
+
def create_gradio_interface():
|
| 40 |
+
"""
|
| 41 |
+
Creates the Gradio user interface for AI Guru Astrologer.
|
| 42 |
+
"""
|
| 43 |
+
# Title and description for the interface
|
| 44 |
+
title = "AI Guru Astrologer"
|
| 45 |
+
description = "Enter your details below to get personalized horoscope predictions from the AI Guru Astrologer."
|
| 46 |
+
|
| 47 |
+
# Input components for the user's details (using gr.components instead of gr.inputs)
|
| 48 |
+
name_input = gr.Textbox(label="Name", placeholder="Enter your name")
|
| 49 |
+
year_input = gr.Number(label="Year of Birth")
|
| 50 |
+
day_input = gr.Number(label="Day of Birth")
|
| 51 |
+
month_input = gr.Number(label="Month of Birth")
|
| 52 |
+
hour_input = gr.Number(label="Hour of Birth (24-hour format)")
|
| 53 |
+
minutes_input = gr.Number(label="Minute of Birth")
|
| 54 |
+
city_input = gr.Textbox(label="City of Birth", placeholder="Enter the city of your birth")
|
| 55 |
+
nation_input = gr.Textbox(label="Nation (Country Code)", placeholder="Enter the country code (e.g., IN, US)")
|
| 56 |
+
question_input = gr.Textbox(label="Your Question for the Guru", placeholder="Enter your personal question (e.g., What is my career path?)")
|
| 57 |
+
|
| 58 |
+
# Output component for the response (using gr.components instead of gr.outputs)
|
| 59 |
+
response_output = gr.Textbox(label="AI Guru Astrologer's Response")
|
| 60 |
+
|
| 61 |
+
# Gradio interface layout
|
| 62 |
+
iface = gr.Interface(
|
| 63 |
+
fn=get_horoscope_response,
|
| 64 |
+
inputs=[name_input, year_input, month_input, day_input, hour_input, minutes_input, city_input, nation_input, question_input],
|
| 65 |
+
outputs=[response_output],
|
| 66 |
+
title=title,
|
| 67 |
+
description=description,
|
| 68 |
+
live=False, # The API call will be made when the user clicks the submit button
|
| 69 |
+
allow_flagging="never" # Disable flagging option
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
iface.launch()
|
| 73 |
+
|
| 74 |
+
# Main entry point to run the Gradio interface
|
| 75 |
+
if __name__ == "__main__":
|
| 76 |
+
create_gradio_interface()
|