Spaces:
Sleeping
Sleeping
karthikeyan-r
commited on
Commit
•
e5c7f85
1
Parent(s):
860dd23
Update app.py
Browse files
app.py
CHANGED
@@ -259,20 +259,23 @@ class ChatDocumentQA:
|
|
259 |
|
260 |
def gradio_interface(self) -> None:
|
261 |
"""Create a Gradio interface for the chatbot."""
|
262 |
-
with gr.Blocks(css
|
263 |
-
|
264 |
-
|
265 |
-
<center
|
266 |
-
<
|
267 |
-
|
|
|
|
|
268 |
state = gr.State(self._get_empty_state())
|
269 |
chatbot = gr.Chatbot()
|
270 |
-
|
271 |
with gr.Row():
|
272 |
with gr.Column(scale=0.85):
|
273 |
msg = gr.Textbox(label="Question")
|
274 |
with gr.Column(scale=0.15):
|
275 |
file_output = gr.Textbox(label="File Status")
|
|
|
276 |
with gr.Row():
|
277 |
with gr.Column(scale=0.85):
|
278 |
clear = gr.ClearButton([msg, chatbot])
|
@@ -280,15 +283,22 @@ class ChatDocumentQA:
|
|
280 |
upload_button = gr.UploadButton(
|
281 |
"Browse File",
|
282 |
file_types=[".txt", ".pdf", ".doc", ".docx", ".csv"],
|
283 |
-
file_count="multiple",
|
|
|
284 |
)
|
|
|
285 |
with gr.Row():
|
286 |
with gr.Column(scale=1):
|
287 |
-
input_url = gr.Textbox(label="
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
|
|
|
|
|
|
|
|
292 |
|
293 |
demo.launch()
|
294 |
|
|
|
259 |
|
260 |
def gradio_interface(self) -> None:
|
261 |
"""Create a Gradio interface for the chatbot."""
|
262 |
+
with gr.Blocks(css="style.css", theme="shivi/calm_seafoam") as demo:
|
263 |
+
gr.HTML("""
|
264 |
+
<center class="darkblue" style="text-align:center;padding:30px;">
|
265 |
+
<center>
|
266 |
+
<h1 style="color:#fff">Virtual Assistant Chatbot</h1>
|
267 |
+
</center>
|
268 |
+
""")
|
269 |
+
|
270 |
state = gr.State(self._get_empty_state())
|
271 |
chatbot = gr.Chatbot()
|
272 |
+
|
273 |
with gr.Row():
|
274 |
with gr.Column(scale=0.85):
|
275 |
msg = gr.Textbox(label="Question")
|
276 |
with gr.Column(scale=0.15):
|
277 |
file_output = gr.Textbox(label="File Status")
|
278 |
+
|
279 |
with gr.Row():
|
280 |
with gr.Column(scale=0.85):
|
281 |
clear = gr.ClearButton([msg, chatbot])
|
|
|
283 |
upload_button = gr.UploadButton(
|
284 |
"Browse File",
|
285 |
file_types=[".txt", ".pdf", ".doc", ".docx", ".csv"],
|
286 |
+
file_count="multiple",
|
287 |
+
variant="primary"
|
288 |
)
|
289 |
+
|
290 |
with gr.Row():
|
291 |
with gr.Column(scale=1):
|
292 |
+
input_url = gr.Textbox(label="URLs")
|
293 |
+
|
294 |
+
# Submit button for URL input
|
295 |
+
input_url.submit(self._get_urls_knowledge_base, inputs=input_url, outputs=[file_output, state])
|
296 |
+
|
297 |
+
# Upload button for file input
|
298 |
+
upload_button.upload(self._get_documents_knowledge_base, inputs=upload_button, outputs=[file_output, state])
|
299 |
+
|
300 |
+
# Submit button for question input
|
301 |
+
msg.submit(self._get_response, inputs=[msg, chatbot, state, upload_button], outputs=[msg, chatbot])
|
302 |
|
303 |
demo.launch()
|
304 |
|