Samuel-DD07 commited on
Commit
04fd816
·
1 Parent(s): b953108

Mise à jour de l'interface utilisateur du chatbot

Browse files
Files changed (1) hide show
  1. app.py +32 -22
app.py CHANGED
@@ -241,35 +241,33 @@ body,html {
241
 
242
  import gradio as gr
243
 
244
- # Placeholder for the generate_text function (you need to define it according to your requirements)
245
- def generate_text(text):
246
- return f"Mock response to: {text}"
247
-
248
  theme = gr.themes.Base(primary_hue="slate")
249
 
250
- suggestion = ["What are the latest advancements in cancer research?",
251
- "What is the impact of diet on heart disease according to recent studies?",
252
- "What are the usual causes of lung pain?"]
253
 
254
- def respond(message, chat_history):
255
  response = generate_text(message)
256
- chat_history.append(("user", message))
257
- chat_history.append(("bot", response))
258
- return chat_history
259
 
260
- def suggestion1(chat_history):
261
  response = generate_text(suggestion[0])
262
- chat_history.append(("user", suggestion[0]))
263
- chat_history.append(("bot", response))
264
- return chat_history
 
 
265
 
266
- # Assuming generate_text, suggestion2, and suggestion3 functions are similar to suggestion1
 
 
 
267
 
268
  user_profile_image = "https://github.com/LucasAguetai/ALOQAS/blob/main/Ressources/ALOQAS%20logo.png?raw=true"
269
  bot_profile_image = "https://github.com/LucasAguetai/ALOQAS/blob/main/Ressources/ALOQAS%20logo.png?raw=true"
270
 
271
- # Assuming 'css' variable is defined elsewhere or you need to include your CSS code
272
- with gr.Blocks(theme=theme) as demo: # Removed 'css=css' due to undefined variable
273
  gr.Markdown("""
274
  <div id='header'>
275
  <h1 id='main-title'>ALOQAS</h1>
@@ -278,14 +276,26 @@ with gr.Blocks(theme=theme) as demo: # Removed 'css=css' due to undefined varia
278
  </div>
279
  """)
280
  with gr.Column(elem_id="chat-interface"):
281
- chat = gr.Chatbot(elem_id="chat-messages", show_label=False, avatar_images=[user_profile_image, bot_profile_image], history=[])
282
  with gr.Row(elem_id="suggestions"):
283
  sugg1 = gr.Button(suggestion[0], elem_classes="suggestion-btn").click(
284
- suggestion1, inputs=[chat], outputs=chat
 
 
 
 
 
 
285
  )
286
- # Implement suggestion2 and suggestion3 functions for sugg2 and sugg3 if needed
287
  with gr.Row(elem_id="input-area"):
288
  text_input = gr.Textbox(placeholder="Write to ALOQAS...", show_label=False)
289
- text_input.submit(respond, inputs=[text_input, chat], outputs=chat)
 
 
 
 
 
 
290
 
291
  demo.launch(share=False)
 
 
241
 
242
  import gradio as gr
243
 
 
 
 
 
244
  theme = gr.themes.Base(primary_hue="slate")
245
 
246
+ suggestion = ["What are the latest advancements in cancer research ?","What is the impact of diet on heart disease according to recent studies ?","What are the usual causes of lung pain ?"]
 
 
247
 
248
+ def respond(message,chat_history):
249
  response = generate_text(message)
250
+ chat_history.append((message, response))
251
+ return "bot", chat_history
252
+
253
 
254
+ def suggestion1():
255
  response = generate_text(suggestion[0])
256
+ return [suggestion_text_1,response]
257
+ """
258
+ def suggestion2():
259
+ response = generate_text(suggestion_text_2)
260
+ return [["user", suggestion_text_2], ["bot", response]]
261
 
262
+ def suggestion3():
263
+ response = generate_text(suggestion_text_3)
264
+ return [["user", suggestion_text_3], ["bot", response]]
265
+ """
266
 
267
  user_profile_image = "https://github.com/LucasAguetai/ALOQAS/blob/main/Ressources/ALOQAS%20logo.png?raw=true"
268
  bot_profile_image = "https://github.com/LucasAguetai/ALOQAS/blob/main/Ressources/ALOQAS%20logo.png?raw=true"
269
 
270
+ with gr.Blocks(theme=theme, css=css) as demo:
 
271
  gr.Markdown("""
272
  <div id='header'>
273
  <h1 id='main-title'>ALOQAS</h1>
 
276
  </div>
277
  """)
278
  with gr.Column(elem_id="chat-interface"):
279
+ chat = gr.Chatbot(elem_id="chat-messages", show_label=False,avatar_images=[user_profile_image,bot_profile_image])
280
  with gr.Row(elem_id="suggestions"):
281
  sugg1 = gr.Button(suggestion[0], elem_classes="suggestion-btn").click(
282
+ suggestion1, outputs=chat
283
+ )
284
+ sugg2 = gr.Button(suggestion[1], elem_classes="suggestion-btn").click(
285
+ suggestion1, outputs=chat
286
+ )
287
+ sugg3 = gr.Button(suggestion[2], elem_classes="suggestion-btn").click(
288
+ suggestion1, outputs=chat
289
  )
 
290
  with gr.Row(elem_id="input-area"):
291
  text_input = gr.Textbox(placeholder="Write to ALOQAS...", show_label=False)
292
+ #send_button = gr.Button("Send", elem_classes="send")
293
+ #send_button.click(
294
+ # fn=respond,
295
+ # inputs=text_input,
296
+ # outputs=chat
297
+ #)
298
+ text_input.submit(respond, [text_input, chat], [text_input, chat])
299
 
300
  demo.launch(share=False)
301
+