|
|
import gradio as gr |
|
|
import requests |
|
|
|
|
|
|
|
|
def get_response(user_input, language): |
|
|
|
|
|
response = requests.post( |
|
|
"https://aiguruji.quarkgen.ai/templedekho/guruji/v1/ask_chatbot", |
|
|
json={"question": user_input, "language": language} |
|
|
) |
|
|
|
|
|
|
|
|
if response.status_code == 200: |
|
|
answer = response.text |
|
|
return "ποΈ Guruji says: π\n\n" + answer |
|
|
else: |
|
|
return "π Sorry, there was an error with your request." |
|
|
|
|
|
|
|
|
custom_css = """ |
|
|
body { |
|
|
background: linear-gradient(135deg, #ffefba, #ffffff); |
|
|
font-family: 'Georgia', serif; |
|
|
font-size: 18px; |
|
|
} |
|
|
|
|
|
.gradio-container { |
|
|
border: 2px solid #f1c40f; |
|
|
border-radius: 15px; |
|
|
padding: 20px; |
|
|
background-color: rgba(255, 255, 255, 0.9); |
|
|
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.1); |
|
|
} |
|
|
|
|
|
h1 { |
|
|
font-family: 'Georgia', serif; |
|
|
color: #d35400; |
|
|
text-align: center; |
|
|
font-size: 3em; |
|
|
} |
|
|
|
|
|
.gradio-input, .gradio-output { |
|
|
font-family: 'Georgia', serif; |
|
|
font-size: 1.5em; |
|
|
color: #2c3e50; |
|
|
} |
|
|
|
|
|
input, textarea { |
|
|
border-radius: 10px; |
|
|
padding: 15px; |
|
|
font-size: 1.3em; |
|
|
border: 2px solid #e67e22; |
|
|
width: 100%; |
|
|
} |
|
|
|
|
|
textarea { |
|
|
height: 200px; |
|
|
} |
|
|
|
|
|
button { |
|
|
background-color: #e67e22; |
|
|
border-radius: 10px; |
|
|
font-size: 1.5em; |
|
|
padding: 15px; |
|
|
color: white; |
|
|
width: 100%; |
|
|
} |
|
|
|
|
|
button:hover { |
|
|
background-color: #d35400; |
|
|
} |
|
|
|
|
|
footer { |
|
|
color: #7f8c8d; |
|
|
text-align: center; |
|
|
margin-top: 20px; |
|
|
font-size: 1.2em; |
|
|
} |
|
|
""" |
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
|
fn=get_response, |
|
|
inputs=[ |
|
|
gr.Textbox(label="Ask Guruji a question"), |
|
|
gr.Dropdown(label="Select Language", choices=["EN", "HI"], value="EN") |
|
|
], |
|
|
outputs="text", |
|
|
title="ποΈ Temple Dekho Chat Bot ποΈ", |
|
|
description="π’ You can now use, Backend Server is live!\n\nπ Ask a question about temples or rituals and get wise answers from Guruji!", |
|
|
theme="default", |
|
|
css=custom_css |
|
|
) |
|
|
|
|
|
|
|
|
iface.launch(share=True) |
|
|
|