Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| hist = '' | |
| def combinar(nombre,mensaje): | |
| global hist | |
| mensaje = f'[{nombre}]: {mensaje}\n' | |
| hist +=mensaje | |
| return hist | |
| def update(): | |
| global hist | |
| return hist | |
| def vaciar(): | |
| return '' | |
| with gr.Blocks() as app: | |
| upd = gr.Button(value='Update') | |
| chat = gr.TextArea(value=hist, | |
| interactive=False, | |
| lines=6, | |
| show_label=False, | |
| max_lines=6) | |
| upd.click(fn=update, inputs=[],outputs=chat) | |
| with gr.Row(): | |
| with gr.Column(scale=0.3): | |
| username = gr.Textbox(show_label=False,placeholder='Your nickname') | |
| with gr.Column(scale=1): | |
| message = gr.Textbox(placeholder='Your message',show_label=False) | |
| message.submit(fn=combinar,inputs=[username,message],outputs=chat) | |
| message.submit(fn=vaciar,outputs=message) | |
| boton = gr.Button('Send message',live=True) | |
| boton.click(fn=combinar,inputs=[username,message],outputs=chat) | |
| boton.click(fn=vaciar,outputs=message) | |
| app.launch(debug=True) |