wpbcpaz commited on
Commit
40a5cfd
·
verified ·
1 Parent(s): b6a6aaf

Update app.py

Browse files

Novos nichos e estilos adicionados

Files changed (1) hide show
  1. app.py +94 -14
app.py CHANGED
@@ -87,8 +87,22 @@ NICHOS_DISPONIVEIS = [
87
  "Entretenimento",
88
  "Relacionamentos & Comunicação",
89
  "Espiritualidade & Filosofia",
90
- "Dicas Jurídicas e de Segurança Pública"
 
 
 
 
 
 
 
 
 
 
 
 
91
  ]
 
 
92
 
93
  ESTILOS_DISPONIVEIS = [
94
  "Inspirador e motivacional",
@@ -97,9 +111,19 @@ ESTILOS_DISPONIVEIS = [
97
  "Profissional e técnico",
98
  "Controverso e de Debate",
99
  "Curiosidades (Fatos Rápidos)",
100
- "Tutorial/Passo a Passo",
 
 
 
 
 
 
 
 
101
  ]
102
 
 
 
103
  ESTILOS_DE_IMAGEM = {
104
  "Nenhum (Automático)": "standard photography, high quality, 4k",
105
  "Fotografia Vintage": "vintage photography, retro style, film grain, analog",
@@ -151,6 +175,18 @@ NICHOS_CORES = {
151
  "Relacionamentos & Comunicação": "#1e40af", # Medium Blue
152
  "Espiritualidade & Filosofia": "#4c1d95", # Deep Purple
153
  "Dicas Jurídicas e de Segurança Pública": "#1e293b", # Dark Slate
 
 
 
 
 
 
 
 
 
 
 
 
154
  "default": "#334155" # Default Slate
155
  }
156
 
@@ -162,8 +198,8 @@ CACHE_DIR = Path("post_cache")
162
  CACHE_DIR.mkdir(exist_ok=True)
163
 
164
  # Nomes de arquivo padrão para download
165
- CSV_FILENAME = "posthistpeacechatbot001.csv"
166
- ZIP_FILENAME = "postpeacechatbot001.zip"
167
 
168
 
169
  # ============================================
@@ -465,7 +501,6 @@ def _formatar_historico_para_html(history_list):
465
  caracteres = stats.get('caracteres', 0)
466
  hashtags = stats.get('hashtags', 0)
467
 
468
- # CORREÇÃO: Aplicado 'cor_texto_clara' a todos os spans de texto
469
  html += f"""
470
  <div style='border: 1px solid {cor_fundo}; padding: 16px; margin: 12px 0;
471
  border-radius: 8px; background-color: {cor_fundo}; color: {cor_texto_clara};
@@ -1111,15 +1146,52 @@ def gerar_post_interface(tema, nicho, estilo, formato, usar_cache, favorito_chec
1111
  # INTERFACE GRADIO
1112
  # ============================================
1113
 
 
1114
  CSS = """
 
1115
  h3 {
1116
- background-color: #f0f4f8;
1117
  padding: 8px 12px;
1118
  border-radius: 8px;
1119
- color: #1f2937;
1120
  font-weight: 600;
1121
  margin-top: 10px;
1122
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1123
  """
1124
 
1125
  custom_theme = gr.themes.Soft(
@@ -1134,9 +1206,16 @@ _inicializar_firestore()
1134
 
1135
  with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)", css=CSS) as demo:
1136
 
1137
- gr.Markdown("""
1138
- # 🚀 Gerador de Posts e Assistente de Mídias Sociais (Versão 4.1)
1139
- ### Desenvolvido com Hugging Face, Gradio, Llama 3.1 e Firebase
 
 
 
 
 
 
 
1140
  """)
1141
 
1142
  with gr.Tabs() as main_tabs:
@@ -1149,7 +1228,8 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1149
  choices=NICHOS_DISPONIVEIS,
1150
  label="🎯 Nicho",
1151
  value=NICHOS_DISPONIVEIS[0],
1152
- interactive=True
 
1153
  )
1154
 
1155
  estilo_input = gr.Radio(
@@ -1392,7 +1472,8 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1392
  label="🎯 Nicho",
1393
  choices=["Todos"] + NICHOS_DISPONIVEIS,
1394
  value="Todos",
1395
- interactive=True
 
1396
  )
1397
  with gr.Row():
1398
  filtro_estilo_hist = gr.Dropdown(
@@ -1688,5 +1769,4 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1688
 
1689
  # Lançar aplicação
1690
  if __name__ == "__main__":
1691
- demo.launch()
1692
-
 
87
  "Entretenimento",
88
  "Relacionamentos & Comunicação",
89
  "Espiritualidade & Filosofia",
90
+ "Dicas Jurídicas e de Segurança Pública",
91
+ "Advogado / Direito",
92
+ "Psicólogo / Saúde Mental",
93
+ "Terapeuta Holístico / Bem-estar",
94
+ "Arquiteto / Design",
95
+ "Contador / Finanças",
96
+ "Professor de Informática",
97
+ "Professor de Matemática",
98
+ "Professor de Idiomas",
99
+ "Professor de História/Geografia",
100
+ "Pedagogo / Educação Infantil",
101
+ "Datas Comemorativas / Feriados",
102
+ "Guarda Civil Municipal / Segurança Pública"
103
  ]
104
+ # Ordenar nichos alfabeticamente
105
+ NICHOS_DISPONIVEIS.sort()
106
 
107
  ESTILOS_DISPONIVEIS = [
108
  "Inspirador e motivacional",
 
111
  "Profissional e técnico",
112
  "Controverso e de Debate",
113
  "Curiosidades (Fatos Rápidos)",
114
+ "Tutorial/Passo a Passo",
115
+ "Narrativo e envolvente",
116
+ "Sutil e persuasivo",
117
+ "Empático e acolhedor",
118
+ "Analítico e reflexivo",
119
+ "Criativo e visual",
120
+ "Interativo e dinâmico",
121
+ "Claros e objetivos",
122
+ "Inspiracional com storytelling"
123
  ]
124
 
125
+ ESTILOS_DISPONIVEIS.sort()
126
+
127
  ESTILOS_DE_IMAGEM = {
128
  "Nenhum (Automático)": "standard photography, high quality, 4k",
129
  "Fotografia Vintage": "vintage photography, retro style, film grain, analog",
 
175
  "Relacionamentos & Comunicação": "#1e40af", # Medium Blue
176
  "Espiritualidade & Filosofia": "#4c1d95", # Deep Purple
177
  "Dicas Jurídicas e de Segurança Pública": "#1e293b", # Dark Slate
178
+ "Advogado / Direito": "#1e293b",
179
+ "Psicólogo / Saúde Mental": "#1e40af",
180
+ "Terapeuta Holístico / Bem-estar": "#064e3b",
181
+ "Arquiteto / Design": "#374151",
182
+ "Contador / Finanças": "#312e81",
183
+ "Professor de Informática": "#1d4ed8",
184
+ "Professor de Matemática": "#312e81",
185
+ "Professor de Idiomas": "#1e40af",
186
+ "Professor de História/Geografia": "#374151",
187
+ "Pedagogo / Educação Infantil": "#064e3b",
188
+ "Datas Comemorativas / Feriados": "#7e22ce", # Purple
189
+ "Guarda Civil Municipal / Segurança Pública": "#1e3a8a", # Dark Blue
190
  "default": "#334155" # Default Slate
191
  }
192
 
 
198
  CACHE_DIR.mkdir(exist_ok=True)
199
 
200
  # Nomes de arquivo padrão para download
201
+ CSV_FILENAME = "PostHistPeaceChatbot.csv"
202
+ ZIP_FILENAME = "PostPeaceChatbot.zip"
203
 
204
 
205
  # ============================================
 
501
  caracteres = stats.get('caracteres', 0)
502
  hashtags = stats.get('hashtags', 0)
503
 
 
504
  html += f"""
505
  <div style='border: 1px solid {cor_fundo}; padding: 16px; margin: 12px 0;
506
  border-radius: 8px; background-color: {cor_fundo}; color: {cor_texto_clara};
 
1146
  # INTERFACE GRADIO
1147
  # ============================================
1148
 
1149
+ # CSS atualizado com botões e responsividade
1150
  CSS = """
1151
+ /* Estilo dos Títulos (Compatível com Tema Claro/Escuro) */
1152
  h3 {
1153
+ background-color: var(--primary-50);
1154
  padding: 8px 12px;
1155
  border-radius: 8px;
1156
+ color: var(--primary-600);
1157
  font-weight: 600;
1158
  margin-top: 10px;
1159
  }
1160
+
1161
+ /* Responsividade: Empilha colunas em telas pequenas */
1162
+ @media (max-width: 768px) {
1163
+ div.gradio-row {
1164
+ flex-direction: column;
1165
+ }
1166
+ }
1167
+
1168
+ /* Estilo dos Botões Primários (Azul Marinho) */
1169
+ .gradio-button.primary {
1170
+ background: #1e3a8a; /* Azul Marinho (Navy Blue) */
1171
+ color: white;
1172
+ border: none;
1173
+ transition: background 0.2s ease-in-out;
1174
+ }
1175
+ .gradio-button.primary:hover {
1176
+ background: #3b82f6; /* Azul mais suave */
1177
+ color: white;
1178
+ box-shadow: 0 4px 14px 0 rgba(0, 118, 255, 0.39); /* Sombra suave no hover */
1179
+ }
1180
+ .gradio-button.primary:active {
1181
+ background: #2563eb; /* Azul um pouco mais escuro no clique */
1182
+ }
1183
+
1184
+ /* Estilo do Botão Limpar (Vermelho) */
1185
+ .gradio-button.stop {
1186
+ background: #dc2626; /* Vermelho */
1187
+ color: white;
1188
+ border: none;
1189
+ transition: background 0.2s ease-in-out;
1190
+ }
1191
+ .gradio-button.stop:hover {
1192
+ background: #ef4444; /* Vermelho mais suave */
1193
+ color: white;
1194
+ }
1195
  """
1196
 
1197
  custom_theme = gr.themes.Soft(
 
1206
 
1207
  with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)", css=CSS) as demo:
1208
 
1209
+ # Cabeçalho HTML com logo e cores
1210
+ gr.HTML("""
1211
+ <div style="background: linear-gradient(90deg, #1e3a8a, #3b82f6); color: white; padding: 24px; border-radius: 8px; text-align: center; margin-bottom: 10px;">
1212
+ <h1 style="font-size: 2.5rem; margin: 0; padding: 0; line-height: 1; display: flex; align-items: center; justify-content: center; gap: 15px;">
1213
+ <span style="font-size: 2.8rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));">🕊️</span>
1214
+ <span>Peace Chatbot</span>
1215
+ </h1>
1216
+ <p style="font-size: 1.2rem; margin: 12px 0 0 0; opacity: 0.9;">Gerador de Posts e Assistente de Mídias Sociais (Versão 4.1)</p>
1217
+ <p style="font-size: 0.9rem; margin: 4px 0 0 0; opacity: 0.8;">Desenvolvido com Hugging Face, Gradio, Llama 3.1 e Firebase</p>
1218
+ </div>
1219
  """)
1220
 
1221
  with gr.Tabs() as main_tabs:
 
1228
  choices=NICHOS_DISPONIVEIS,
1229
  label="🎯 Nicho",
1230
  value=NICHOS_DISPONIVEIS[0],
1231
+ interactive=True,
1232
+ filterable=True # Adicionado filtro
1233
  )
1234
 
1235
  estilo_input = gr.Radio(
 
1472
  label="🎯 Nicho",
1473
  choices=["Todos"] + NICHOS_DISPONIVEIS,
1474
  value="Todos",
1475
+ interactive=True,
1476
+ filterable=True # Adicionado filtro
1477
  )
1478
  with gr.Row():
1479
  filtro_estilo_hist = gr.Dropdown(
 
1769
 
1770
  # Lançar aplicação
1771
  if __name__ == "__main__":
1772
+ demo.launch()