Spaces:
Runtime error
Runtime error
Samuel-DD07
commited on
Commit
·
b953108
1
Parent(s):
da2afc2
Mise à jour de l'interface de chat et des suggestions
Browse files
app.py
CHANGED
@@ -241,33 +241,35 @@ body,html {
|
|
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
|
|
|
|
|
247 |
|
248 |
-
def respond(message,chat_history):
|
249 |
response = generate_text(message)
|
250 |
-
chat_history.append((
|
251 |
-
|
252 |
-
|
253 |
|
254 |
-
def suggestion1():
|
255 |
response = generate_text(suggestion[0])
|
256 |
-
|
257 |
-
""
|
258 |
-
|
259 |
-
response = generate_text(suggestion_text_2)
|
260 |
-
return [["user", suggestion_text_2], ["bot", response]]
|
261 |
|
262 |
-
|
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=
|
268 |
-
bot_profile_image = "https://github.com/LucasAguetai/ALOQAS/blob/main/Ressources/ALOQAS%20logo.png?raw=
|
269 |
|
270 |
-
|
|
|
271 |
gr.Markdown("""
|
272 |
<div id='header'>
|
273 |
<h1 id='main-title'>ALOQAS</h1>
|
@@ -276,26 +278,14 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
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 |
-
|
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 |
-
|
|
|
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 |
</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)
|
|