File size: 1,173 Bytes
3d97b57
 
83d5461
d25d09c
 
 
3d97b57
6881041
d25d09c
 
 
 
6881041
d25d09c
 
 
 
6881041
d25d09c
 
 
e616a60
6881041
 
d25d09c
 
 
6881041
d25d09c
 
 
 
 
 
 
e616a60
d25d09c
 
 
 
 
 
 
6881041
 
d25d09c
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
45
46
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)