Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from src.brain import generate_answers
|
| 4 |
+
processing = False
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def response(query, history):
|
| 8 |
+
global processing
|
| 9 |
+
processing = True
|
| 10 |
+
output = generate_answers(query)
|
| 11 |
+
history.append((query, output))
|
| 12 |
+
processing = False
|
| 13 |
+
return "", history
|
| 14 |
+
|
| 15 |
+
def loading():
|
| 16 |
+
return "Loading ..."
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
with gr.Blocks(css=css) as app:
|
| 20 |
+
with gr.Column(elem_id="column_container"):
|
| 21 |
+
gr.HTML(title_html)
|
| 22 |
+
chatbot = gr.Chatbot([], elem_id="chatbot")
|
| 23 |
+
with gr.Column():
|
| 24 |
+
send = gr.Label(value="Write your QUESTION bellow and hit ENTER")
|
| 25 |
+
query = gr.Textbox(
|
| 26 |
+
label="Type your questions here:",
|
| 27 |
+
placeholder="What do you want to know?",
|
| 28 |
+
)
|
| 29 |
+
clear = gr.ClearButton([query, chatbot])
|
| 30 |
+
gr.HTML(bts_html)
|
| 31 |
+
query.submit(response, [query, chatbot], [query, chatbot], queue=True)
|
| 32 |
+
|
| 33 |
+
app.launch()
|