Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| # API endpoint URL for the Horoscope API | |
| API_URL = "https://ai-research.quarkgen.ai/templedekho/match_maker/v1" | |
| def get_horoscope_response(name1, year1, month1, day1, hour1, minute1, city1, country1, | |
| name2, year2, month2, day2, hour2, minute2, city2, country2, language): | |
| """ | |
| Send a POST request to the horoscope API with the user-provided parameters. | |
| """ | |
| # Prepare the input payload | |
| payload = { | |
| "name1": name1, | |
| "year1": int(year1), | |
| "month1": int(month1), | |
| "day1": int(day1), | |
| "hour1": int(hour1), | |
| "minute1": int(minute1), | |
| "city1": city1, | |
| "country1": country1, # Fixed key from "county1" to "country1" | |
| "name2": name2, | |
| "year2": int(year2), | |
| "month2": int(month2), | |
| "day2": int(day2), | |
| "hour2": int(hour2), | |
| "minute2": int(minute2), | |
| "city2": city2, | |
| "country2": country2, # Fixed key from "county2" to "country2" | |
| "language": language | |
| } | |
| # Send the POST request | |
| response = requests.post(API_URL, json=payload) | |
| # Check if the request was successful | |
| if response.status_code == 200: | |
| response_data = response.text | |
| return response_data | |
| else: | |
| return f"Sorry, there was an error with your request. Status Code: {response.status_code}" | |
| # 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 Match Maker" | |
| description = "Enter your and your partner's details below to get personalized astrological aspects and match-making predictions from the AI Guru." | |
| # Define inputs for Person 1 | |
| name1 = gr.Textbox(label="Name (Person 1)", placeholder="Enter the name of Person 1") | |
| year1 = gr.Number(label="Birth Year (Person 1)") | |
| month1 = gr.Number(label="Birth Month (Person 1)") | |
| day1 = gr.Number(label="Birth Day (Person 1)") | |
| hour1 = gr.Number(label="Birth Hour (Person 1) (24-hour format)") | |
| minute1 = gr.Number(label="Birth Minute (Person 1)") | |
| city1 = gr.Textbox(label="Birth City (Person 1)", placeholder="Enter the city of birth") | |
| country1 = gr.Textbox(label="Birth Country (Person 1)", placeholder="Enter the country of birth") | |
| # Define inputs for Person 2 | |
| name2 = gr.Textbox(label="Name (Person 2)", placeholder="Enter the name of Person 2") | |
| year2 = gr.Number(label="Birth Year (Person 2)") | |
| month2 = gr.Number(label="Birth Month (Person 2)") | |
| day2 = gr.Number(label="Birth Day (Person 2)") | |
| hour2 = gr.Number(label="Birth Hour (Person 2) (24-hour format)") | |
| minute2 = gr.Number(label="Birth Minute (Person 2)") | |
| city2 = gr.Textbox(label="Birth City (Person 2)", placeholder="Enter the city of birth") | |
| country2 = gr.Textbox(label="Birth Country (Person 2)", placeholder="Enter the country of birth") | |
| # Language selection | |
| language = gr.Textbox(label="Language (Language Code)", placeholder="Enter the Language code (e.g., EN, HI)") | |
| # Output component for the response | |
| response_output = gr.Textbox(label="AI Guru Astrologer's Response") | |
| # Gradio interface layout | |
| iface = gr.Interface( | |
| fn=get_horoscope_response, | |
| inputs=[name1, year1, month1, day1, hour1, minute1, city1, country1, name2, year2, month2, day2, hour2, minute2, city2, country2, language], | |
| 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 | |
| ) | |
| # Launch the Gradio interface | |
| iface.launch() | |
| # Main entry point to run the Gradio interface | |
| if __name__ == "__main__": | |
| create_gradio_interface() | |