|
import gradio as gr |
|
import requests |
|
|
|
|
|
API_URL = "https://ai-research.quarkgen.ai/templedekho/horoscope/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. |
|
""" |
|
|
|
payload = { |
|
"name": name, |
|
"year": int(year), |
|
"month": int(month), |
|
"day": int(day), |
|
"hour": int(hour), |
|
"minutes": int(minutes), |
|
"city": city, |
|
"nation": nation, |
|
"question": question, |
|
"language": language, |
|
} |
|
|
|
response = requests.post(API_URL, json=payload) |
|
|
|
|
|
|
|
if response.status_code == 200: |
|
response_data = response.text |
|
|
|
return response_data |
|
|
|
else: |
|
return "Sorry, there was an error with your request." |
|
|
|
|
|
|
|
def create_gradio_interface(): |
|
""" |
|
Creates the Gradio user interface for AI Guru Astrologer. |
|
""" |
|
|
|
title = "AI Guru Astrologer" |
|
description = "Enter your details below to get personalized horoscope predictions from the AI Guru Astrologer." |
|
|
|
|
|
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 Languages code (e.g., EN: English, HI: Hindi)") |
|
question_input = gr.Textbox(label="Your Question for the Guru", placeholder="Enter your personal question (e.g., What is my career path?)") |
|
|
|
|
|
response_output = gr.Textbox(label="AI Guru Astrologer's Response") |
|
|
|
|
|
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, |
|
allow_flagging="never" |
|
) |
|
|
|
iface.launch() |
|
|
|
|
|
if __name__ == "__main__": |
|
create_gradio_interface() |
|
|