Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,65 +1,46 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
def responder(message, history):
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
primary_hue="blue",
|
| 8 |
-
secondary_hue="slate",
|
| 9 |
-
neutral_hue="slate"
|
| 10 |
-
).set(
|
| 11 |
-
body_background_fill="#0f172a",
|
| 12 |
-
body_text_color="#f8fafc",
|
| 13 |
-
block_background_fill="#111827",
|
| 14 |
-
block_border_color="#1f2937",
|
| 15 |
-
button_primary_background_fill="#2563eb",
|
| 16 |
-
button_primary_background_fill_hover="#1d4ed8",
|
| 17 |
-
input_background_fill="#0b1220"
|
| 18 |
-
)
|
| 19 |
|
| 20 |
custom_css = """
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
#title-box h1 {
|
| 26 |
-
font-size: 2.4rem;
|
| 27 |
-
margin-bottom: 8px;
|
| 28 |
}
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
}
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
padding-bottom: 30px;
|
| 37 |
}
|
| 38 |
-
footer {display: none !important;}
|
| 39 |
"""
|
| 40 |
|
| 41 |
-
with gr.Blocks(
|
| 42 |
-
gr.
|
| 43 |
-
|
| 44 |
-
<h1>🤖 Meu Chatbot</h1>
|
| 45 |
-
<p>Teste simples para confirmar que o bot responde.</p>
|
| 46 |
-
</div>
|
| 47 |
-
""")
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
]
|
| 57 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
-
demo.launch(
|
| 61 |
-
server_name="0.0.0.0",
|
| 62 |
-
server_port=7860,
|
| 63 |
-
theme=theme,
|
| 64 |
-
css=custom_css
|
| 65 |
-
)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
def responder(message, history):
|
| 4 |
+
history = history or []
|
| 5 |
+
history.append((message, f"Tu disseste: {message}"))
|
| 6 |
+
return "", history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
custom_css = """
|
| 9 |
+
.gradio-container {
|
| 10 |
+
max-width: 1000px !important;
|
| 11 |
+
margin: 0 auto !important;
|
| 12 |
+
padding-top: 20px !important;
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
+
|
| 15 |
+
#chatbox {
|
| 16 |
+
height: 500px !important;
|
| 17 |
+
overflow-y: auto !important;
|
| 18 |
}
|
| 19 |
+
|
| 20 |
+
footer {
|
| 21 |
+
display: none !important;
|
|
|
|
| 22 |
}
|
|
|
|
| 23 |
"""
|
| 24 |
|
| 25 |
+
with gr.Blocks(css=custom_css) as demo:
|
| 26 |
+
gr.Markdown("# 🤖 Meu Chatbot")
|
| 27 |
+
gr.Markdown("Versão com altura fixa para o chat, para a textbox não descer.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
chatbot = gr.Chatbot(elem_id="chatbox")
|
| 30 |
+
|
| 31 |
+
with gr.Row():
|
| 32 |
+
msg = gr.Textbox(
|
| 33 |
+
placeholder="Escreve aqui a tua mensagem...",
|
| 34 |
+
show_label=False,
|
| 35 |
+
scale=8
|
|
|
|
| 36 |
)
|
| 37 |
+
send = gr.Button("Enviar", scale=1)
|
| 38 |
+
|
| 39 |
+
clear = gr.Button("Nova conversa")
|
| 40 |
+
|
| 41 |
+
send.click(responder, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 42 |
+
msg.submit(responder, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 43 |
+
clear.click(lambda: ([], ""), outputs=[chatbot, msg])
|
| 44 |
|
| 45 |
if __name__ == "__main__":
|
| 46 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|