Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -236,17 +236,46 @@ def bot_kadi(history):
|
|
| 236 |
yield history, formatted_references
|
| 237 |
|
| 238 |
def main():
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
|
| 251 |
initialize()
|
| 252 |
main()
|
|
|
|
| 236 |
yield history, formatted_references
|
| 237 |
|
| 238 |
def main():
|
| 239 |
+
with gr.Blocks() as demo:
|
| 240 |
+
gr.Markdown("## Kadi4Mat - AI Chat-Bot")
|
| 241 |
+
gr.Markdown("AI assistant for Kadi4Mat based on RAG architecture powered by LLM")
|
| 242 |
+
|
| 243 |
+
with gr.Tab("Kadi4Mat - AI Assistant"):
|
| 244 |
+
with gr.Row():
|
| 245 |
+
with gr.Column(scale=7):
|
| 246 |
+
chatbot = gr.Chatbot([], elem_id="chatbot", label="Kadi Bot", bubble_full_width=False, show_copy_button=True)
|
| 247 |
+
user_txt = gr.Textbox(label="Question", placeholder="Type in your question and press Enter or click Submit")
|
| 248 |
+
|
| 249 |
+
with gr.Row():
|
| 250 |
+
with gr.Column(scale=1):
|
| 251 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
| 252 |
+
with gr.Column(scale=1):
|
| 253 |
+
clear_btn = gr.Button("Clear", variant="stop")
|
| 254 |
+
|
| 255 |
+
gr.Examples(
|
| 256 |
+
examples=[
|
| 257 |
+
"Can you help me setting up Kadi?",
|
| 258 |
+
"Who is working on Kadi4Mat?",
|
| 259 |
+
"What are the steps to implement a plugin in Kadi4Mat?",
|
| 260 |
+
"Would Kadi4Mat be worth investing in?",
|
| 261 |
+
],
|
| 262 |
+
inputs=user_txt,
|
| 263 |
+
outputs=chatbot,
|
| 264 |
+
fn=add_text,
|
| 265 |
+
label="Try asking...",
|
| 266 |
+
cache_examples=False,
|
| 267 |
+
examples_per_page=3,
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
with gr.Column(scale=3):
|
| 271 |
+
with gr.Tab("References"):
|
| 272 |
+
doc_citation = gr.HTML("<p>References used in answering the question will be displayed below.</p>")
|
| 273 |
+
|
| 274 |
+
user_txt.submit(check_input_text, user_txt, None).success(add_text, [chatbot, user_txt], [chatbot, user_txt]).then(bot_kadi, [chatbot], [chatbot, doc_citation])
|
| 275 |
+
submit_btn.click(check_input_text, user_txt, None).success(add_text, [chatbot, user_txt], [chatbot, user_txt]).then(bot_kadi, [chatbot], [chatbot, doc_citation])
|
| 276 |
+
clear_btn.click(lambda: None, None, chatbot, queue=False)
|
| 277 |
+
|
| 278 |
+
demo.launch()
|
| 279 |
|
| 280 |
initialize()
|
| 281 |
main()
|