Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
# Function to call the Flask API and return the LLM response
|
5 |
+
def get_match_making_result(
|
6 |
+
name1, year1, month1, day1, hour1, minute1, city1, country1,
|
7 |
+
name2, year2, month2, day2, hour2, minute2, city2, country2, language
|
8 |
+
):
|
9 |
+
# Define the API endpoint
|
10 |
+
api_url = "http://127.0.0.1:9096/templedekho/match_maker/v1"
|
11 |
+
|
12 |
+
# Prepare the payload to send to the API
|
13 |
+
data = {
|
14 |
+
"name1": name1, "year1": year1, "month1": month1, "day1": day1, "hour1": hour1, "minute1": minute1, "city1": city1, "country1": country1,
|
15 |
+
"name2": name2, "year2": year2, "month2": month2, "day2": day2, "hour2": hour2, "minute2": minute2, "city2": city2, "country2": country2,
|
16 |
+
"language": language
|
17 |
+
}
|
18 |
+
|
19 |
+
# Make the POST request to the API
|
20 |
+
response = requests.post(api_url, json=data)
|
21 |
+
|
22 |
+
# Check if the request was successful
|
23 |
+
if response.status_code == 200:
|
24 |
+
# Return the response from the API
|
25 |
+
return response.text
|
26 |
+
else:
|
27 |
+
return f"Error: {response.status_code}, {response.text}"
|
28 |
+
|
29 |
+
# Create the Gradio interface
|
30 |
+
def create_gradio_interface():
|
31 |
+
with gr.Blocks() as interface:
|
32 |
+
# Add input fields for Person 1
|
33 |
+
with gr.Row():
|
34 |
+
with gr.Column():
|
35 |
+
name1 = gr.Textbox(label="Name (Person 1)", placeholder="Enter Name of Person 1")
|
36 |
+
year1 = gr.Number(label="Birth Year (Person 1)", placeholder="Enter Birth Year of Person 1")
|
37 |
+
month1 = gr.Number(label="Birth Month (Person 1)", placeholder="Enter Birth Month of Person 1")
|
38 |
+
day1 = gr.Number(label="Birth Day (Person 1)", placeholder="Enter Birth Day of Person 1")
|
39 |
+
hour1 = gr.Number(label="Birth Hour (Person 1)", placeholder="Enter Birth Hour of Person 1")
|
40 |
+
minute1 = gr.Number(label="Birth Minute (Person 1)", placeholder="Enter Birth Minute of Person 1")
|
41 |
+
city1 = gr.Textbox(label="Birth City (Person 1)", placeholder="Enter Birth City of Person 1")
|
42 |
+
country1 = gr.Textbox(label="Birth Country (Person 1)", placeholder="Enter Birth Country of Person 1")
|
43 |
+
|
44 |
+
# Add input fields for Person 2
|
45 |
+
with gr.Row():
|
46 |
+
with gr.Column():
|
47 |
+
name2 = gr.Textbox(label="Name (Person 2)", placeholder="Enter Name of Person 2")
|
48 |
+
year2 = gr.Number(label="Birth Year (Person 2)", placeholder="Enter Birth Year of Person 2")
|
49 |
+
month2 = gr.Number(label="Birth Month (Person 2)", placeholder="Enter Birth Month of Person 2")
|
50 |
+
day2 = gr.Number(label="Birth Day (Person 2)", placeholder="Enter Birth Day of Person 2")
|
51 |
+
hour2 = gr.Number(label="Birth Hour (Person 2)", placeholder="Enter Birth Hour of Person 2")
|
52 |
+
minute2 = gr.Number(label="Birth Minute (Person 2)", placeholder="Enter Birth Minute of Person 2")
|
53 |
+
city2 = gr.Textbox(label="Birth City (Person 2)", placeholder="Enter Birth City of Person 2")
|
54 |
+
country2 = gr.Textbox(label="Birth Country (Person 2)", placeholder="Enter Birth Country of Person 2")
|
55 |
+
|
56 |
+
# Add language selection
|
57 |
+
language = gr.Radio(
|
58 |
+
choices=["EN", "HI"],
|
59 |
+
label="Select Response Language",
|
60 |
+
value="EN"
|
61 |
+
)
|
62 |
+
|
63 |
+
# Add a submit button and display the results
|
64 |
+
result = gr.Textbox(label="Generated Match Making Result", placeholder="Result will be displayed here...")
|
65 |
+
submit_btn = gr.Button("Submit")
|
66 |
+
|
67 |
+
# Call the API when the button is clicked
|
68 |
+
submit_btn.click(
|
69 |
+
get_match_making_result,
|
70 |
+
inputs=[name1, year1, month1, day1, hour1, minute1, city1, country1, name2, year2, month2, day2, hour2, minute2, city2, country2, language],
|
71 |
+
outputs=result
|
72 |
+
)
|
73 |
+
|
74 |
+
return interface
|
75 |
+
|
76 |
+
# Start the Gradio interface
|
77 |
+
if __name__ == "__main__":
|
78 |
+
title = "AI Guru Match Maker"
|
79 |
+
description = "Enter your and your partner's details below to get personalized Astrological Aspects and Match Making predictions from the AI Guru Astrologer."
|
80 |
+
interface = create_gradio_interface()
|
81 |
+
interface.launch()
|