wpbcpaz commited on
Commit
5c52d67
·
verified ·
1 Parent(s): 164da12

Update app.py

Browse files

Melhoria de responsividade do chatbot

Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -126,7 +126,8 @@ ESTILOS_INSTRUCOES = {
126
  "Empático e acolhedor": "empathetic and welcoming, using a supportive, understanding, and gentle tone.",
127
  "Inspirador e motivacional": "inspiring and motivational, using uplifting language and calls to action.",
128
  "Inspiracional com storytelling": "inspirational storytelling, weaving a personal story to motivate others.",
129
- "Interativo e dinâmico": "interactive and dynamic, asking questions, using polls, and encouraging engagement.",
 
130
  "Narrativo e envolvente": "narrative and engaging, like telling a short story with a beginning, middle, and end.",
131
  "Profissional e técnico": "professional and technical, using formal language, data, and expert terminology.",
132
  "Sutil e persuasivo": "subtle and persuasive, gently guiding the reader to a conclusion or action.",
@@ -506,9 +507,9 @@ def _formatar_historico_para_html(history_list):
506
  try:
507
  data = datetime.fromisoformat(data_str).strftime("%d/%m/%Y %H:%M")
508
  except ValueError:
509
- data = datetime.strptime(data_str, "%Y-%m-%d %H:%M:%S").strftime("%d/%m/%Y %H:%M")
510
  else:
511
- data = "Data Indisponível"
512
  except Exception as e:
513
  print(f"Erro ao formatar data: {e}, Data original: {post.get('DataHora')}")
514
  data = "Data Inválida"
@@ -524,8 +525,8 @@ def _formatar_historico_para_html(history_list):
524
 
525
  html += f"""
526
  <div style='border: 1px solid {cor_fundo}; padding: 16px; margin: 12px 0;
527
- border-radius: 8px; background-color: {cor_fundo}; color: {cor_texto_clara};
528
- box-shadow: 0 4px 6px rgba(0,0,0,0.1); cursor: default;'>
529
  <div style='display: flex; justify-content: space-between; margin-bottom: 8px;'>
530
  <strong style='font-size: 16px; color: {cor_texto_clara};'>{favorito_icon} {post.get('Tema', 'Sem título')}</strong>
531
  <span style='color: {cor_texto_clara}; font-size: 12px;'>{data}</span>
@@ -1241,15 +1242,14 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1241
  interactive=True,
1242
  filterable=True
1243
  )
1244
-
1245
  estilo_input = gr.Radio(
1246
  choices=ESTILOS_DISPONIVEIS,
1247
  label="🎨 Estilo",
1248
  value=ESTILOS_DISPONIVEIS[0],
1249
- interactive=True,
1250
- columns=2 # CORREÇÃO: Removido
1251
  )
1252
-
1253
  tema_input = gr.Textbox(
1254
  label="📝 Tema do Post",
1255
  placeholder="Ex: Transforme seu corpo, transforme sua vida"
@@ -1267,7 +1267,7 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1267
  label="Gerar imagem?",
1268
  value=False
1269
  )
1270
-
1271
  descricao_img_input = gr.Textbox(
1272
  label="📸 Descrição da imagem (em Português)",
1273
  placeholder="Ex: Pessoa correndo ao nascer do sol",
@@ -1297,7 +1297,7 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1297
  visible=False,
1298
  interactive=True
1299
  )
1300
-
1301
  def toggle_descricao_img(gerar):
1302
  return (
1303
  gr.Textbox(visible=gerar),
@@ -1305,7 +1305,7 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1305
  gr.Radio(visible=gerar),
1306
  gr.Dropdown(visible=gerar)
1307
  )
1308
-
1309
  gerar_img_checkbox.change(
1310
  toggle_descricao_img,
1311
  inputs=[gerar_img_checkbox],
@@ -1334,12 +1334,12 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1334
 
1335
  with gr.Column(scale=1):
1336
  gr.Markdown("### 📋 3. Resultado")
1337
-
1338
  status_output = gr.HTML(
1339
  label="Status",
1340
  value=criar_alerta('info', 'Pronto para gerar!')
1341
  )
1342
-
1343
  texto_output = gr.Textbox(
1344
  label="Texto Gerado",
1345
  lines=10,
@@ -1356,7 +1356,7 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1356
 
1357
  with gr.Row():
1358
  limpar_btn = gr.Button("🧹 Limpar Tudo", variant="stop")
1359
-
1360
  gr.Markdown("") # Espaçamento
1361
  imagem_output = gr.Image(
1362
  label="Imagem Gerada",
@@ -1431,7 +1431,7 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1431
  chat_input = gr.Textbox(
1432
  show_label=False,
1433
  placeholder="Digite sua mensagem aqui...",
1434
- scale=7
1435
  )
1436
  submit_btn = gr.Button("Enviar", variant="primary", scale=1)
1437
 
@@ -1463,8 +1463,8 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1463
  )
1464
 
1465
  chatbot_para_interface.like(
1466
- fn=print_like_dislike,
1467
- inputs=None,
1468
  outputs=None
1469
  )
1470
 
 
126
  "Empático e acolhedor": "empathetic and welcoming, using a supportive, understanding, and gentle tone.",
127
  "Inspirador e motivacional": "inspiring and motivational, using uplifting language and calls to action.",
128
  "Inspiracional com storytelling": "inspirational storytelling, weaving a personal story to motivate others.",
129
+ "Interativo e dinâmico": "interactive and dynamic,
130
+ asking questions, using polls, and encouraging engagement.",
131
  "Narrativo e envolvente": "narrative and engaging, like telling a short story with a beginning, middle, and end.",
132
  "Profissional e técnico": "professional and technical, using formal language, data, and expert terminology.",
133
  "Sutil e persuasivo": "subtle and persuasive, gently guiding the reader to a conclusion or action.",
 
507
  try:
508
  data = datetime.fromisoformat(data_str).strftime("%d/%m/%Y %H:%M")
509
  except ValueError:
510
+ data = datetime.strptime(data_str, "%Y-%m-%d %H:%M:%S").strftime("%d/%m/%Y %H:%M")
511
  else:
512
+ data = "Data Indisponível"
513
  except Exception as e:
514
  print(f"Erro ao formatar data: {e}, Data original: {post.get('DataHora')}")
515
  data = "Data Inválida"
 
525
 
526
  html += f"""
527
  <div style='border: 1px solid {cor_fundo}; padding: 16px; margin: 12px 0;
528
+ border-radius: 8px; background-color: {cor_fundo}; color: {cor_texto_clara};
529
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1); cursor: default;'>
530
  <div style='display: flex; justify-content: space-between; margin-bottom: 8px;'>
531
  <strong style='font-size: 16px; color: {cor_texto_clara};'>{favorito_icon} {post.get('Tema', 'Sem título')}</strong>
532
  <span style='color: {cor_texto_clara}; font-size: 12px;'>{data}</span>
 
1242
  interactive=True,
1243
  filterable=True
1244
  )
1245
+
1246
  estilo_input = gr.Radio(
1247
  choices=ESTILOS_DISPONIVEIS,
1248
  label="🎨 Estilo",
1249
  value=ESTILOS_DISPONIVEIS[0],
1250
+ interactive=True
 
1251
  )
1252
+
1253
  tema_input = gr.Textbox(
1254
  label="📝 Tema do Post",
1255
  placeholder="Ex: Transforme seu corpo, transforme sua vida"
 
1267
  label="Gerar imagem?",
1268
  value=False
1269
  )
1270
+
1271
  descricao_img_input = gr.Textbox(
1272
  label="📸 Descrição da imagem (em Português)",
1273
  placeholder="Ex: Pessoa correndo ao nascer do sol",
 
1297
  visible=False,
1298
  interactive=True
1299
  )
1300
+
1301
  def toggle_descricao_img(gerar):
1302
  return (
1303
  gr.Textbox(visible=gerar),
 
1305
  gr.Radio(visible=gerar),
1306
  gr.Dropdown(visible=gerar)
1307
  )
1308
+
1309
  gerar_img_checkbox.change(
1310
  toggle_descricao_img,
1311
  inputs=[gerar_img_checkbox],
 
1334
 
1335
  with gr.Column(scale=1):
1336
  gr.Markdown("### 📋 3. Resultado")
1337
+
1338
  status_output = gr.HTML(
1339
  label="Status",
1340
  value=criar_alerta('info', 'Pronto para gerar!')
1341
  )
1342
+
1343
  texto_output = gr.Textbox(
1344
  label="Texto Gerado",
1345
  lines=10,
 
1356
 
1357
  with gr.Row():
1358
  limpar_btn = gr.Button("🧹 Limpar Tudo", variant="stop")
1359
+
1360
  gr.Markdown("") # Espaçamento
1361
  imagem_output = gr.Image(
1362
  label="Imagem Gerada",
 
1431
  chat_input = gr.Textbox(
1432
  show_label=False,
1433
  placeholder="Digite sua mensagem aqui...",
1434
+ scale=10 # <-- MELHORIA APLICADA AQUI
1435
  )
1436
  submit_btn = gr.Button("Enviar", variant="primary", scale=1)
1437
 
 
1463
  )
1464
 
1465
  chatbot_para_interface.like(
1466
+ fn=print_like_dislike,
1467
+ inputs=None,
1468
  outputs=None
1469
  )
1470