kheopss commited on
Commit
6e95c88
·
verified ·
1 Parent(s): 8131b59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -17
app.py CHANGED
@@ -296,21 +296,62 @@ def process_final(user_prom, history):
296
  yield response.text
297
 
298
  from gradio import gradio as gr
299
- mychatbot = gr.Chatbot(
300
- avatar_images=["./user_icon.png", "./metro.png"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True,
301
- )
302
- description = """
303
- <p>
304
- <center>
305
- <img src="https://www.nicecotedazur.org/wp-content/themes/mnca/images/logo-metropole-nca.png" alt="rick" width="250"/>
306
- </center>
307
- </p>
308
- <p style="text-align:right"> Made by KHEOPS AI</p>
309
- """
310
- demo = gr.ChatInterface(
311
- fn=process_final,
312
- chatbot=mychatbot,
313
- title="METROPOLE SIGNATAIRE CHATBOT",
314
- description=description,
315
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  demo.launch(share=True, debug =True)
 
296
  yield response.text
297
 
298
  from gradio import gradio as gr
299
+ # mychatbot = gr.Chatbot(
300
+ # avatar_images=["./user_icon.png", "./metro.png"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True,
301
+ # )
302
+ # description = """
303
+ # <p>
304
+ # <center>
305
+ # <img src="https://www.nicecotedazur.org/wp-content/themes/mnca/images/logo-metropole-nca.png" alt="rick" width="250"/>
306
+ # </center>
307
+ # </p>
308
+ # <p style="text-align:right"> Made by KHEOPS AI</p>
309
+ # """
310
+ # demo = gr.ChatInterface(
311
+ # fn=process_final,
312
+ # chatbot=mychatbot,
313
+ # title="METROPOLE SIGNATAIRE CHATBOT",
314
+ # description=description,
315
+ # )
316
+ # demo.launch(share=True, debug =True)
317
+ # Gradio Interface
318
+ with gr.Blocks() as demo:
319
+ with gr.Row():
320
+ description = """
321
+ <h1 style ="font-size: 36px;font-weight: bold;"><center>METROPOLE SIGNATAIRE CHATBOT</center></h1>
322
+ <p>
323
+ <center>
324
+ <img src="https://www.nicecotedazur.org/wp-content/themes/mnca/images/logo-metropole-nca.png" alt="rick" width="250"/>
325
+ </center>
326
+ </p>
327
+ <p style="text-align:right"> Développé par KHEOPS AI</p>
328
+ """
329
+ gr.HTML(description)
330
+ chatbot = gr.Chatbot(height = "20rem")
331
+ msg = gr.Textbox(show_label=False,placeholder = "Poser votre question ...")
332
+ clear = gr.Button("Réinitialiser")
333
+
334
+ def user(user_message, history):
335
+ # Capture the user message and pass it to 'process_final'
336
+ return "", history + [[user_message, None]]
337
+
338
+ def bot(history):
339
+ # Get the last user message from the history
340
+ user_message = history[-1][0]
341
+
342
+ # Process it using the 'process_final' function
343
+ gen = process_final(user_message, history)
344
+
345
+ bot_message = ""
346
+ for chunk in gen:
347
+ bot_message += chunk
348
+ history[-1][1] = bot_message # Update bot response in the conversation history
349
+ yield history
350
+
351
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
352
+ bot, chatbot, chatbot
353
+ )
354
+
355
+ clear.click(lambda: None, None, chatbot, queue=False)
356
+
357
  demo.launch(share=True, debug =True)