Programer123 commited on
Commit
d25d09c
·
verified ·
1 Parent(s): e616a60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -51
app.py CHANGED
@@ -1,65 +1,46 @@
1
  import gradio as gr
2
 
3
  def responder(message, history):
4
- return f"Tu disseste: {message}"
5
-
6
- theme = gr.themes.Soft(
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
- #title-box {
22
- text-align: center;
23
- padding: 30px 10px 10px 10px;
24
- }
25
- #title-box h1 {
26
- font-size: 2.4rem;
27
- margin-bottom: 8px;
28
  }
29
- #title-box p {
30
- color: #cbd5e1;
31
- font-size: 1rem;
 
32
  }
33
- #chat-wrap {
34
- max-width: 950px;
35
- margin: 0 auto;
36
- padding-bottom: 30px;
37
  }
38
- footer {display: none !important;}
39
  """
40
 
41
- with gr.Blocks(fill_height=True) as demo:
42
- gr.HTML("""
43
- <div id="title-box">
44
- <h1>🤖 Meu Chatbot</h1>
45
- <p>Teste simples para confirmar que o bot responde.</p>
46
- </div>
47
- """)
48
 
49
- with gr.Column(elem_id="chat-wrap"):
50
- gr.ChatInterface(
51
- fn=responder,
52
- examples=[
53
- "Olá",
54
- "Como estás?",
55
- "Explica-me o que é Gradio"
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)