Upload 2 files
Browse files- app.py +29 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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://ai-research.quarkgen.ai/templedekho/v1/ask_chatbot",
|
9 |
+
json={"question": user_input}
|
10 |
+
)
|
11 |
+
|
12 |
+
# Check if the request was successful
|
13 |
+
if response.status_code == 200:
|
14 |
+
# Extract the answer from the response
|
15 |
+
answer = response.text # Assuming the API response is already a string
|
16 |
+
return answer
|
17 |
+
else:
|
18 |
+
return "Sorry, there was an error with your request."
|
19 |
+
|
20 |
+
# Create the Gradio interface
|
21 |
+
iface = gr.Interface(
|
22 |
+
fn=get_response, # Function to call when user submits input
|
23 |
+
inputs="text", # Input type
|
24 |
+
outputs="text", # Output type
|
25 |
+
title="Temple Dekho Chat Bot",
|
26 |
+
description="Ask a question about temples or rituals and get answers from the Guru!"
|
27 |
+
)
|
28 |
+
|
29 |
+
iface.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
requests
|
2 |
+
gradio
|