File size: 2,410 Bytes
a9264ff
 
 
efbd578
 
a9264ff
 
efbd578
 
a9264ff
 
 
 
f649886
7e8b10d
a9264ff
7e8b10d
 
 
 
 
 
 
efbd578
7e8b10d
 
 
 
 
 
 
 
 
 
 
 
 
 
efbd578
7e8b10d
 
 
 
efbd578
7e8b10d
 
 
 
 
efbd578
 
7e8b10d
 
 
 
 
 
 
 
 
 
 
efbd578
ebcdc16
7e8b10d
 
 
 
 
 
 
 
 
 
 
 
efbd578
7e8b10d
 
f649886
a9264ff
 
 
efbd578
 
 
 
a9264ff
7e8b10d
 
2bfe575
7e8b10d
a9264ff
 
7e8b10d
 
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import gradio as gr
import requests

# Function to make the API request
def get_response(user_input, language):
    # Make a POST request to the API
    response = requests.post(
        "https://aiguruji.quarkgen.ai/templedekho/guruji/v1/ask_chatbot",
        json={"question": user_input, "language": language}
    )
    
    # Check if the request was successful
    if response.status_code == 200:
        answer = response.text  # API response is already a string
        return "πŸ•‰οΈ Guruji says: πŸ™\n\n" + answer
    else:
        return "πŸ™ Sorry, there was an error with your request."

# Custom CSS to make the interface more spiritual and aesthetic
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;
}
"""

# Create the Gradio interface
iface = gr.Interface(
    fn=get_response,  # Function to call when user submits input
    inputs=[
        gr.Textbox(label="Ask Guruji a question"),  # User's question
        gr.Dropdown(label="Select Language", choices=["EN", "HI"], value="EN")  # Language selection
    ],
    outputs="text",  # Output type
    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",  # Use the default theme
    css=custom_css  # Apply the custom CSS for styling
)

# Launch the Gradio app with a specific server port
iface.launch(share=True)