Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
-
|
5 |
-
def get_response(user_input):
|
6 |
# Make a POST request to the API
|
7 |
response = requests.post(
|
8 |
-
"https://
|
9 |
-
json={"question": user_input}
|
10 |
)
|
11 |
|
12 |
# Check if the request was successful
|
@@ -16,13 +16,12 @@ def get_response(user_input):
|
|
16 |
else:
|
17 |
return "π Sorry, there was an error with your request."
|
18 |
|
19 |
-
|
20 |
# Custom CSS to make the interface more spiritual and aesthetic
|
21 |
custom_css = """
|
22 |
body {
|
23 |
background: linear-gradient(135deg, #ffefba, #ffffff);
|
24 |
font-family: 'Georgia', serif;
|
25 |
-
font-size: 18px;
|
26 |
}
|
27 |
|
28 |
.gradio-container {
|
@@ -37,19 +36,19 @@ h1 {
|
|
37 |
font-family: 'Georgia', serif;
|
38 |
color: #d35400;
|
39 |
text-align: center;
|
40 |
-
font-size: 3em;
|
41 |
}
|
42 |
|
43 |
.gradio-input, .gradio-output {
|
44 |
font-family: 'Georgia', serif;
|
45 |
-
font-size: 1.5em;
|
46 |
color: #2c3e50;
|
47 |
}
|
48 |
|
49 |
input, textarea {
|
50 |
border-radius: 10px;
|
51 |
-
padding: 15px;
|
52 |
-
font-size: 1.3em;
|
53 |
border: 2px solid #e67e22;
|
54 |
width: 100%;
|
55 |
}
|
@@ -61,7 +60,7 @@ textarea {
|
|
61 |
button {
|
62 |
background-color: #e67e22;
|
63 |
border-radius: 10px;
|
64 |
-
font-size: 1.5em;
|
65 |
padding: 15px;
|
66 |
color: white;
|
67 |
width: 100%;
|
@@ -75,18 +74,20 @@ footer {
|
|
75 |
color: #7f8c8d;
|
76 |
text-align: center;
|
77 |
margin-top: 20px;
|
78 |
-
font-size: 1.2em;
|
79 |
}
|
80 |
"""
|
81 |
|
82 |
# Create the Gradio interface
|
83 |
iface = gr.Interface(
|
84 |
fn=get_response, # Function to call when user submits input
|
85 |
-
inputs=
|
|
|
|
|
|
|
86 |
outputs="text", # Output type
|
87 |
title="ποΈ Temple Dekho Chat Bot ποΈ",
|
88 |
description="π’ You can now use, Backend Server is live!\n\nπ Ask a question about temples or rituals and get wise answers from Guruji!",
|
89 |
-
#theme= "abidlabs/pakistan",
|
90 |
theme="default", # Use the default theme
|
91 |
css=custom_css # Apply the custom CSS for styling
|
92 |
)
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
+
# Function to make the API request
|
5 |
+
def get_response(user_input, language):
|
6 |
# Make a POST request to the API
|
7 |
response = requests.post(
|
8 |
+
"https://aiguruji.quarkgen.ai/templedekho/guruji/v1/ask_chatbot",
|
9 |
+
json={"question": user_input, "language": language}
|
10 |
)
|
11 |
|
12 |
# Check if the request was successful
|
|
|
16 |
else:
|
17 |
return "π Sorry, there was an error with your request."
|
18 |
|
|
|
19 |
# Custom CSS to make the interface more spiritual and aesthetic
|
20 |
custom_css = """
|
21 |
body {
|
22 |
background: linear-gradient(135deg, #ffefba, #ffffff);
|
23 |
font-family: 'Georgia', serif;
|
24 |
+
font-size: 18px;
|
25 |
}
|
26 |
|
27 |
.gradio-container {
|
|
|
36 |
font-family: 'Georgia', serif;
|
37 |
color: #d35400;
|
38 |
text-align: center;
|
39 |
+
font-size: 3em;
|
40 |
}
|
41 |
|
42 |
.gradio-input, .gradio-output {
|
43 |
font-family: 'Georgia', serif;
|
44 |
+
font-size: 1.5em;
|
45 |
color: #2c3e50;
|
46 |
}
|
47 |
|
48 |
input, textarea {
|
49 |
border-radius: 10px;
|
50 |
+
padding: 15px;
|
51 |
+
font-size: 1.3em;
|
52 |
border: 2px solid #e67e22;
|
53 |
width: 100%;
|
54 |
}
|
|
|
60 |
button {
|
61 |
background-color: #e67e22;
|
62 |
border-radius: 10px;
|
63 |
+
font-size: 1.5em;
|
64 |
padding: 15px;
|
65 |
color: white;
|
66 |
width: 100%;
|
|
|
74 |
color: #7f8c8d;
|
75 |
text-align: center;
|
76 |
margin-top: 20px;
|
77 |
+
font-size: 1.2em;
|
78 |
}
|
79 |
"""
|
80 |
|
81 |
# Create the Gradio interface
|
82 |
iface = gr.Interface(
|
83 |
fn=get_response, # Function to call when user submits input
|
84 |
+
inputs=[
|
85 |
+
gr.Textbox(label="Ask Guruji a question"), # User's question
|
86 |
+
gr.Dropdown(label="Select Language", choices=["EN", "HI"], value="EN") # Language selection
|
87 |
+
],
|
88 |
outputs="text", # Output type
|
89 |
title="ποΈ Temple Dekho Chat Bot ποΈ",
|
90 |
description="π’ You can now use, Backend Server is live!\n\nπ Ask a question about temples or rituals and get wise answers from Guruji!",
|
|
|
91 |
theme="default", # Use the default theme
|
92 |
css=custom_css # Apply the custom CSS for styling
|
93 |
)
|