File size: 1,098 Bytes
be5fb95
 
 
 
 
 
 
 
 
934163b
 
 
 
be5fb95
 
 
934163b
be5fb95
 
934163b
be5fb95
934163b
be5fb95
 
 
 
 
934163b
 
be5fb95
 
672ac4d
be5fb95
672ac4d
be5fb95
 
 
 
672ac4d
be5fb95
 
 
 
ef79eae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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)