Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,7 @@ CHAT_TEMPLATE= """{% for message in messages %}
|
|
43 |
tokenizer.chat_template = CHAT_TEMPLATE
|
44 |
|
45 |
chat_history = [] # Historial de chat global
|
46 |
-
|
47 |
def generate_response(user_input):
|
48 |
global chat_history
|
49 |
# Agregar input del usuario al historial
|
@@ -68,15 +68,19 @@ def generate_response(user_input):
|
|
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 |
-
|
|
|
74 |
return [("", "")]
|
75 |
|
76 |
|
77 |
def clear_chat_and_history():
|
78 |
global chat_history
|
79 |
-
|
|
|
|
|
80 |
# Devolver valores que efectivamente "limpien" los componentes de Gradio visualmente
|
81 |
# En este caso, estamos limpiando el Textbox y el Chatbot, pero como el Chatbot
|
82 |
# no puede ser "limpiado" directamente de esta manera, simplemente retornamos una lista vacía
|
|
|
43 |
tokenizer.chat_template = CHAT_TEMPLATE
|
44 |
|
45 |
chat_history = [] # Historial de chat global
|
46 |
+
chatbot_text = []
|
47 |
def generate_response(user_input):
|
48 |
global chat_history
|
49 |
# Agregar input del usuario al historial
|
|
|
68 |
return generated_text
|
69 |
|
70 |
def respond(message):
|
71 |
+
global chatbot_text
|
72 |
if message: # Verificar si el mensaje no está vacío
|
73 |
bot_response = generate_response(message)
|
74 |
+
chatbot_text.append((message, bot_response))
|
75 |
+
return chatbot_text
|
76 |
return [("", "")]
|
77 |
|
78 |
|
79 |
def clear_chat_and_history():
|
80 |
global chat_history
|
81 |
+
global chatbot_text
|
82 |
+
chat_history.clear()# Vaciar el historial de chat
|
83 |
+
chatbot_text.clear()
|
84 |
# Devolver valores que efectivamente "limpien" los componentes de Gradio visualmente
|
85 |
# En este caso, estamos limpiando el Textbox y el Chatbot, pero como el Chatbot
|
86 |
# no puede ser "limpiado" directamente de esta manera, simplemente retornamos una lista vacía
|