Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def responder(message, history): | |
| history = history or [] | |
| history.append((message, f"Tu disseste: {message}")) | |
| return "", history | |
| custom_css = """ | |
| .gradio-container { | |
| max-width: 1000px !important; | |
| margin: 0 auto !important; | |
| padding-top: 20px !important; | |
| } | |
| #chatbox { | |
| height: 500px !important; | |
| overflow-y: auto !important; | |
| } | |
| footer { | |
| display: none !important; | |
| } | |
| """ | |
| with gr.Blocks(css=custom_css) as demo: | |
| gr.Markdown("# 🤖 Meu Chatbot") | |
| gr.Markdown("Versão com altura fixa para o chat, para a textbox não descer.") | |
| chatbot = gr.Chatbot(elem_id="chatbox") | |
| with gr.Row(): | |
| msg = gr.Textbox( | |
| placeholder="Escreve aqui a tua mensagem...", | |
| show_label=False, | |
| scale=8 | |
| ) | |
| send = gr.Button("Enviar", scale=1) | |
| clear = gr.Button("Nova conversa") | |
| send.click(responder, inputs=[msg, chatbot], outputs=[msg, chatbot]) | |
| msg.submit(responder, inputs=[msg, chatbot], outputs=[msg, chatbot]) | |
| clear.click(lambda: ([], ""), outputs=[chatbot, msg]) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860) |