Update app.py
Browse files
app.py
CHANGED
@@ -171,7 +171,7 @@ def process_query(query: str, first_turn: bool = False):
|
|
171 |
|
172 |
process_log.append(f"Wisal: {result}")
|
173 |
_save_process_log(process_log)
|
174 |
-
return
|
175 |
|
176 |
# Gradio Interface
|
177 |
def main_pipeline_with_doc_and_history(query, doc_file, doc_type, history):
|
@@ -213,10 +213,13 @@ def main_pipeline_with_doc(query, doc_file, doc_type):
|
|
213 |
else:
|
214 |
return "Invalid document type."
|
215 |
def pipeline_with_history(message, doc_file, doc_type, history):
|
|
|
|
|
216 |
response = main_pipeline_with_doc(message, doc_file, doc_type)
|
217 |
history = history + [[message, response]]
|
218 |
return history, ""
|
219 |
|
|
|
220 |
with gr.Blocks(title="Wisal Chatbot", theme=gr.themes.Base()) as demo:
|
221 |
gr.Markdown("# π€ Wisal: Autism AI Assistant")
|
222 |
|
@@ -233,14 +236,14 @@ with gr.Blocks(title="Wisal Chatbot", theme=gr.themes.Base()) as demo:
|
|
233 |
label="Document Type"
|
234 |
)
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
|
242 |
-
|
243 |
-
|
244 |
|
245 |
# with gr.Tab("π Domain Knowledge RAG"):
|
246 |
# RAG_Domain_know_doc.demo.render()
|
|
|
171 |
|
172 |
process_log.append(f"Wisal: {result}")
|
173 |
_save_process_log(process_log)
|
174 |
+
return result
|
175 |
|
176 |
# Gradio Interface
|
177 |
def main_pipeline_with_doc_and_history(query, doc_file, doc_type, history):
|
|
|
213 |
else:
|
214 |
return "Invalid document type."
|
215 |
def pipeline_with_history(message, doc_file, doc_type, history):
|
216 |
+
if not message.strip():
|
217 |
+
return history, ""
|
218 |
response = main_pipeline_with_doc(message, doc_file, doc_type)
|
219 |
history = history + [[message, response]]
|
220 |
return history, ""
|
221 |
|
222 |
+
|
223 |
with gr.Blocks(title="Wisal Chatbot", theme=gr.themes.Base()) as demo:
|
224 |
gr.Markdown("# π€ Wisal: Autism AI Assistant")
|
225 |
|
|
|
236 |
label="Document Type"
|
237 |
)
|
238 |
|
239 |
+
send_btn.click(
|
240 |
+
fn=pipeline_with_history,
|
241 |
+
inputs=[user_input, doc_file, doc_type, chatbot],
|
242 |
+
outputs=[chatbot, user_input]
|
243 |
+
)
|
244 |
|
245 |
+
clear_btn = gr.Button("Clear Chat")
|
246 |
+
clear_btn.click(lambda: [], outputs=[chatbot])
|
247 |
|
248 |
# with gr.Tab("π Domain Knowledge RAG"):
|
249 |
# RAG_Domain_know_doc.demo.render()
|