Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| # API endpoint URL for the Horoscope API | |
| API_URL = "https://ai-research.quarkgen.ai/templedekho/numerology/v1" | |
| def get_horoscope_response(name, year, month, day, hour, minutes, city, nation, language, question): | |
| """ | |
| Send a POST request to the horoscope API with the user-provided parameters. | |
| """ | |
| # Prepare the input payload | |
| payload = { | |
| "name": name, | |
| "year": int(year), | |
| "month": int(month), | |
| "day": int(day), | |
| "hour": int(hour), | |
| "minutes": int(minutes), | |
| "city": city, | |
| "nation": nation, | |
| "language": language, | |
| "question": question | |
| } | |
| response = requests.post(API_URL, json=payload) | |
| # Check if there was an error in the API response | |
| if response.status_code == 200: | |
| response_data = response.text | |
| # return response_data | |
| return response_data | |
| else: | |
| return "Sorry, there was an error with your request." | |
| # Define the Gradio interface | |
| def create_gradio_interface(): | |
| """ | |
| Creates the Gradio user interface for AI Guru Astrologer. | |
| """ | |
| # Title and description for the interface | |
| title = "AI Guru Numerology" | |
| description = "Enter your details below to get personalized horoscope predictions from the AI Guru Astrologer." | |
| # Input components for the user's details (using gr.components instead of gr.inputs) | |
| name_input = gr.Textbox(label="Name", placeholder="Enter your name") | |
| year_input = gr.Number(label="Year of Birth") | |
| day_input = gr.Number(label="Day of Birth") | |
| month_input = gr.Number(label="Month of Birth") | |
| hour_input = gr.Number(label="Hour of Birth (24-hour format)") | |
| minutes_input = gr.Number(label="Minute of Birth") | |
| city_input = gr.Textbox(label="City of Birth", placeholder="Enter the city of your birth") | |
| nation_input = gr.Textbox(label="Nation (Country Code)", placeholder="Enter the country code (e.g., IN, US)") | |
| language_input = gr.Textbox(label="Language (Language Code)", placeholder="Enter the Language code (e.g., EN, HI)") | |
| question_input = gr.Textbox(label="Your Question for the Guru", placeholder="Enter your personal question (e.g., What is my career path?)") | |
| # Output component for the response (using gr.components instead of gr.outputs) | |
| response_output = gr.Textbox(label="AI Guru Astrologer's Response") | |
| # Gradio interface layout | |
| iface = gr.Interface( | |
| fn=get_horoscope_response, | |
| inputs=[name_input, year_input, month_input, day_input, hour_input, minutes_input, city_input, nation_input, language_input, question_input], | |
| outputs=[response_output], | |
| title=title, | |
| description=description, | |
| live=False, # The API call will be made when the user clicks the submit button | |
| allow_flagging="never" # Disable flagging option | |
| ) | |
| iface.launch() | |
| # Main entry point to run the Gradio interface | |
| if __name__ == "__main__": | |
| create_gradio_interface() | |