Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,54 +62,21 @@ def generate_response(message, history):
|
|
| 62 |
|
| 63 |
return response
|
| 64 |
|
| 65 |
-
#
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
.textbox, .button {
|
| 81 |
-
width: 100% !important; /* Asegura que input y botones ocupen todo el ancho */
|
| 82 |
-
}
|
| 83 |
-
@media (max-width: 600px) {
|
| 84 |
-
#chatbot {
|
| 85 |
-
height: 400px !important; /* Ajuste para móviles */
|
| 86 |
-
}
|
| 87 |
-
}
|
| 88 |
-
"""
|
| 89 |
-
|
| 90 |
-
with gr.Blocks(css=custom_css) as demo:
|
| 91 |
-
gr.Markdown("# Gemma-3-4B-IT Chat en ZeroGPU\nChatbot con google/gemma-3-4b-it. Estilos arreglados para evitar descuadre.")
|
| 92 |
-
|
| 93 |
-
chatbot = gr.Chatbot(elem_id="chatbot")
|
| 94 |
-
msg = gr.Textbox(placeholder="Escribe tu mensaje...", label="Mensaje")
|
| 95 |
-
clear = gr.Button("Limpiar")
|
| 96 |
-
|
| 97 |
-
def respond(message, chat_history):
|
| 98 |
-
bot_message = generate_response(message, chat_history)
|
| 99 |
-
chat_history.append((message, bot_message))
|
| 100 |
-
return "", chat_history
|
| 101 |
-
|
| 102 |
-
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 103 |
-
clear.click(lambda: ([], ""), None, chatbot)
|
| 104 |
-
|
| 105 |
-
gr.Examples(
|
| 106 |
-
examples=[
|
| 107 |
-
["Hola, ¿cómo estás?"],
|
| 108 |
-
["Explica qué es la IA."],
|
| 109 |
-
["Cuéntame un chiste."]
|
| 110 |
-
],
|
| 111 |
-
inputs=[msg]
|
| 112 |
-
)
|
| 113 |
|
| 114 |
if __name__ == "__main__":
|
| 115 |
demo.launch()
|
|
|
|
| 62 |
|
| 63 |
return response
|
| 64 |
|
| 65 |
+
# DISEÑO STANDARD GENERICO: Usando gr.ChatInterface sin CSS custom para evitar errores de estilos/404
|
| 66 |
+
demo = gr.ChatInterface(
|
| 67 |
+
fn=generate_response,
|
| 68 |
+
title="Gemma-3-4B-IT Chat",
|
| 69 |
+
description="Chatbot con google/gemma-3-4b-it en ZeroGPU. Diseño por defecto de Gradio.",
|
| 70 |
+
examples=[
|
| 71 |
+
["Hola, ¿cómo estás?"],
|
| 72 |
+
["Explica qué es la IA."],
|
| 73 |
+
["Cuéntame un chiste."]
|
| 74 |
+
],
|
| 75 |
+
cache_examples=True,
|
| 76 |
+
retry_btn="Reintentar",
|
| 77 |
+
undo_btn="Deshacer",
|
| 78 |
+
clear_btn="Limpiar chat"
|
| 79 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
if __name__ == "__main__":
|
| 82 |
demo.launch()
|