Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -64,11 +64,10 @@ def generate_response(user_input):
|
|
64 |
|
65 |
# Agregar la respuesta del bot al historial
|
66 |
chat_history.append({"content": generated_text, "role": "assistant"})
|
67 |
-
|
68 |
return generated_text
|
69 |
|
70 |
def respond(message):
|
71 |
-
print(chat_history)
|
72 |
if message: # Verificar si el mensaje no est谩 vac铆o
|
73 |
bot_response = generate_response(message)
|
74 |
return [("", bot_response)]
|
@@ -79,17 +78,18 @@ with gr.Blocks() as demo:
|
|
79 |
msg = gr.Textbox(label="Tu mensaje", placeholder="Escribe aqu铆...", lines=1)
|
80 |
send_btn = gr.Button("Enviar")
|
81 |
chatbot = gr.Chatbot()
|
82 |
-
clear_btn = gr.Button("Limpiar Chat")
|
83 |
-
|
|
|
84 |
# Acci贸n al presionar el bot贸n Enviar
|
85 |
send_btn.click(fn=respond, inputs=msg, outputs=chatbot)
|
86 |
|
87 |
# Funci贸n para limpiar el chat al presionar el bot贸n Limpiar
|
88 |
-
def clear_chat():
|
89 |
-
global chat_history
|
90 |
-
chat_history.clear()
|
91 |
-
chatbot.clear() # Limpiar el componente Chatbot
|
92 |
-
|
93 |
-
clear_btn.click(fn=clear_chat, inputs=None, outputs=chatbot)
|
94 |
|
|
|
|
|
95 |
demo.launch()
|
|
|
64 |
|
65 |
# Agregar la respuesta del bot al historial
|
66 |
chat_history.append({"content": generated_text, "role": "assistant"})
|
67 |
+
print(chat_history)
|
68 |
return generated_text
|
69 |
|
70 |
def respond(message):
|
|
|
71 |
if message: # Verificar si el mensaje no est谩 vac铆o
|
72 |
bot_response = generate_response(message)
|
73 |
return [("", bot_response)]
|
|
|
78 |
msg = gr.Textbox(label="Tu mensaje", placeholder="Escribe aqu铆...", lines=1)
|
79 |
send_btn = gr.Button("Enviar")
|
80 |
chatbot = gr.Chatbot()
|
81 |
+
#clear_btn = gr.Button("Limpiar Chat")
|
82 |
+
clear = gr.ClearButton([msg, chatbot, chat_history])
|
83 |
+
|
84 |
# Acci贸n al presionar el bot贸n Enviar
|
85 |
send_btn.click(fn=respond, inputs=msg, outputs=chatbot)
|
86 |
|
87 |
# Funci贸n para limpiar el chat al presionar el bot贸n Limpiar
|
88 |
+
#def clear_chat():
|
89 |
+
#global chat_history
|
90 |
+
#chat_history.clear()
|
91 |
+
#chatbot.clear() # Limpiar el componente Chatbot
|
|
|
|
|
92 |
|
93 |
+
#clear_btn.click(fn=clear_chat, inputs=None, outputs=chatbot)
|
94 |
+
|
95 |
demo.launch()
|