File size: 3,048 Bytes
54266f6 3b214bc 54266f6 320333d 54266f6 15b718d 54266f6 5b6f14c 54266f6 5b6f14c 54266f6 5b6f14c 54266f6 5b6f14c 54266f6 251d270 54266f6 145beea 15b718d 54266f6 5b6f14c 54266f6 15b718d 5b6f14c 54266f6 fdde8cd 54266f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
import gradio as gr
import requests
# API endpoint URL for the Horoscope API
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.
"""
# 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,
"question": question,
"language": language,
}
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 Astrologer"
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 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?)")
# 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()
|