wpbcpaz commited on
Commit
b49bdf0
·
verified ·
1 Parent(s): 464e938

Update app.py

Browse files

Organizar a Interface com gr.Accordion

Files changed (1) hide show
  1. app.py +94 -98
app.py CHANGED
@@ -787,7 +787,7 @@ def otimizar_prompt_imagem(descricao_pt, estilo_escolhido, filtro_escolhido):
787
 
788
  def criar_negative_prompt():
789
  """Cria um prompt negativo padrão para evitar resultados ruins."""
790
- return "low quality, blurry, (deformed hands:1.3), (bad anatomy:1.3), (mutilated:1.2), (extra limbs:1.2), watermark, text, signature, ugly, tiling"
791
 
792
  def gerar_imagem_robusta(descricao_pt, estilo_escolhido, qualidade, filtro_escolhido, progress=None):
793
  """
@@ -1140,105 +1140,103 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1140
  with gr.TabItem("✨ Gerar Post", id=0):
1141
  with gr.Row():
1142
  with gr.Column(scale=1):
1143
- gr.Markdown("### ⚙️ 1. Configurações do Texto")
1144
-
1145
- nicho_input = gr.Dropdown(
1146
- choices=NICHOS_DISPONIVEIS,
1147
- label="🎯 Nicho",
1148
- value=NICHOS_DISPONIVEIS[0],
1149
- interactive=True
1150
- )
1151
-
1152
- estilo_input = gr.Radio(
1153
- choices=ESTILOS_DISPONIVEIS,
1154
- label="🎨 Estilo",
1155
- value=ESTILOS_DISPONIVEIS[0],
1156
- interactive=True
1157
- )
1158
-
1159
- tema_input = gr.Textbox(
1160
- label="📝 Tema do Post",
1161
- placeholder="Ex: Transforme seu corpo, transforme sua vida"
1162
- )
1163
 
1164
- formato_input = gr.Radio(
1165
- choices=list(FORMATO_CONFIGS.keys()),
1166
- label="📄 Formato de Saída",
1167
- value=list(FORMATO_CONFIGS.keys())[0],
1168
- interactive=True
1169
- )
1170
 
1171
- with gr.Group():
1172
- gr.Markdown("### ⚡ Performance")
1173
- usar_cache_checkbox = gr.Checkbox(
1174
- label="Usar cache",
1175
- value=True,
1176
- info="Reutiliza resultados anteriores (mais rápido)"
1177
  )
1178
- limpar_cache_btn = gr.Button(
1179
- "🗑️ Limpar Cache",
1180
- size="sm",
1181
- variant="secondary"
 
1182
  )
1183
-
1184
- gr.Markdown("") # Espaçamento
1185
-
1186
- gr.Markdown("### 🎨 2. Configurações da Imagem (Opcional)")
1187
-
1188
- gerar_img_checkbox = gr.Checkbox(
1189
- label="Gerar imagem?",
1190
- value=False
1191
- )
1192
-
1193
- descricao_img_input = gr.Textbox(
1194
- label="📸 Descrição da imagem (em Português)",
1195
- placeholder="Ex: Pessoa correndo ao nascer do sol",
1196
- visible=False
1197
- )
1198
-
1199
- estilo_img_input = gr.Dropdown(
1200
- label="🖼️ Estilo da Imagem",
1201
- choices=list(ESTILOS_DE_IMAGEM.keys()),
1202
- value="Nenhum (Automático)",
1203
- visible=False,
1204
- interactive=True
1205
- )
1206
-
1207
- qualidade_img_input = gr.Radio(
1208
- label="⏱️ Qualidade da Imagem",
1209
- choices=["Rápida", "Balanceada", "Alta"],
1210
- value="Balanceada",
1211
- visible=False,
1212
- interactive=True
1213
- )
1214
-
1215
- filtro_img_input = gr.Dropdown(
1216
- label="🌈 Filtro da Imagem",
1217
- choices=list(FILTROS_IMAGEM.keys()),
1218
- value="Nenhum",
1219
- visible=False,
1220
- interactive=True
1221
- )
1222
-
1223
- def toggle_descricao_img(gerar):
1224
- return (
1225
- gr.Textbox(visible=gerar),
1226
- gr.Dropdown(visible=gerar),
1227
- gr.Radio(visible=gerar),
1228
- gr.Dropdown(visible=gerar)
1229
  )
1230
-
1231
- gerar_img_checkbox.change(
1232
- toggle_descricao_img,
1233
- inputs=[gerar_img_checkbox],
1234
- outputs=[descricao_img_input, estilo_img_input, qualidade_img_input, filtro_img_input]
1235
- )
1236
-
1237
- favorito_checkbox = gr.Checkbox(label="⭐ Favoritar este post?", value=False)
1238
 
1239
- gr.Markdown("") # Espaçamento
1240
-
1241
- gerar_btn = gr.Button(" Gerar Post", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1242
 
1243
  with gr.Column(scale=1):
1244
  gr.Markdown("### 📋 3. Resultado")
@@ -1260,10 +1258,8 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1260
  editor_locked = gr.State(True)
1261
  refinar_btn = gr.Button("✏️ Refinar Post")
1262
 
1263
- gr.Markdown("ℹ️ *Use o ícone de prancheta (📋) no canto superior direito da caixa de texto para copiar o conteúdo.*")
1264
-
1265
  with gr.Row():
1266
- # CORREÇÃO: Removido o botão de cópia problemático
1267
  limpar_btn = gr.Button("🧹 Limpar Tudo", variant="stop")
1268
 
1269
  gr.Markdown("") # Espaçamento
@@ -1628,7 +1624,7 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
1628
  fn=resetar_analytics,
1629
  inputs=None,
1630
  outputs=[analytics_display],
1631
- js="() => confirm('Tem certeza que deseja resetar TODOS os dados de analytics e cache? Esta ação não pode ser desfeita.')"
1632
  )
1633
 
1634
  # Lançar aplicação
 
787
 
788
  def criar_negative_prompt():
789
  """Cria um prompt negativo padrão para evitar resultados ruins."""
790
+ return "low quality, blurry, (deformed hands:1.3), (bad anatomy:1.loca3), (mutilated:1.2), (extra limbs:1.2), watermark, text, signature, ugly, tiling"
791
 
792
  def gerar_imagem_robusta(descricao_pt, estilo_escolhido, qualidade, filtro_escolhido, progress=None):
793
  """
 
1140
  with gr.TabItem("✨ Gerar Post", id=0):
1141
  with gr.Row():
1142
  with gr.Column(scale=1):
1143
+ # MELHORIA: gr.Accordion
1144
+ with gr.Accordion("⚙️ 1. Configurações do Texto", open=True):
1145
+ nicho_input = gr.Dropdown(
1146
+ choices=NICHOS_DISPONIVEIS,
1147
+ label="🎯 Nicho",
1148
+ value=NICHOS_DISPONIVEIS[0],
1149
+ interactive=True
1150
+ )
1151
+
1152
+ estilo_input = gr.Radio(
1153
+ choices=ESTILOS_DISPONIVEIS,
1154
+ label="🎨 Estilo",
1155
+ value=ESTILOS_DISPONIVEIS[0],
1156
+ interactive=True
1157
+ )
1158
+
1159
+ tema_input = gr.Textbox(
1160
+ label="📝 Tema do Post",
1161
+ placeholder="Ex: Transforme seu corpo, transforme sua vida"
1162
+ )
1163
 
1164
+ formato_input = gr.Radio(
1165
+ choices=list(FORMATO_CONFIGS.keys()),
1166
+ label="📄 Formato de Saída",
1167
+ value=list(FORMATO_CONFIGS.keys())[0],
1168
+ interactive=True
1169
+ )
1170
 
1171
+ with gr.Accordion("🎨 2. Configurações da Imagem (Opcional)", open=False):
1172
+ gerar_img_checkbox = gr.Checkbox(
1173
+ label="Gerar imagem?",
1174
+ value=False
 
 
1175
  )
1176
+
1177
+ descricao_img_input = gr.Textbox(
1178
+ label="📸 Descrição da imagem (em Português)",
1179
+ placeholder="Ex: Pessoa correndo ao nascer do sol",
1180
+ visible=False
1181
  )
1182
+
1183
+ estilo_img_input = gr.Dropdown(
1184
+ label="🖼️ Estilo da Imagem",
1185
+ choices=list(ESTILOS_DE_IMAGEM.keys()),
1186
+ value="Nenhum (Automático)",
1187
+ visible=False,
1188
+ interactive=True
1189
+ )
1190
+
1191
+ qualidade_img_input = gr.Radio(
1192
+ label="⏱️ Qualidade da Imagem",
1193
+ choices=["Rápida", "Balanceada", "Alta"],
1194
+ value="Balanceada",
1195
+ visible=False,
1196
+ interactive=True
1197
+ )
1198
+
1199
+ filtro_img_input = gr.Dropdown(
1200
+ label="🌈 Filtro da Imagem",
1201
+ choices=list(FILTROS_IMAGEM.keys()),
1202
+ value="Nenhum",
1203
+ visible=False,
1204
+ interactive=True
1205
+ )
1206
+
1207
+ def toggle_descricao_img(gerar):
1208
+ return (
1209
+ gr.Textbox(visible=gerar),
1210
+ gr.Dropdown(visible=gerar),
1211
+ gr.Radio(visible=gerar),
1212
+ gr.Dropdown(visible=gerar)
1213
+ )
1214
+
1215
+ gerar_img_checkbox.change(
1216
+ toggle_descricao_img,
1217
+ inputs=[gerar_img_checkbox],
1218
+ outputs=[descricao_img_input, estilo_img_input, qualidade_img_input, filtro_img_input]
 
 
 
 
 
 
 
 
 
1219
  )
 
 
 
 
 
 
 
 
1220
 
1221
+ with gr.Accordion("⚡ Performance e Ações", open=True):
1222
+ with gr.Group():
1223
+ gr.Markdown("### Performance")
1224
+ usar_cache_checkbox = gr.Checkbox(
1225
+ label="Usar cache",
1226
+ value=True,
1227
+ info="Reutiliza resultados anteriores (mais rápido)"
1228
+ )
1229
+ limpar_cache_btn = gr.Button(
1230
+ "🗑️ Limpar Cache",
1231
+ size="sm",
1232
+ variant="secondary"
1233
+ )
1234
+
1235
+ gr.Markdown("") # Espaçamento
1236
+ favorito_checkbox = gr.Checkbox(label="⭐ Favoritar este post?", value=False)
1237
+
1238
+ gr.Markdown("") # Espaçamento
1239
+ gerar_btn = gr.Button("✨ Gerar Post", variant="primary")
1240
 
1241
  with gr.Column(scale=1):
1242
  gr.Markdown("### 📋 3. Resultado")
 
1258
  editor_locked = gr.State(True)
1259
  refinar_btn = gr.Button("✏️ Refinar Post")
1260
 
 
 
1261
  with gr.Row():
1262
+ copiar_btn = gr.Button("📋 Copiar Texto", variant="secondary")
1263
  limpar_btn = gr.Button("🧹 Limpar Tudo", variant="stop")
1264
 
1265
  gr.Markdown("") # Espaçamento
 
1624
  fn=resetar_analytics,
1625
  inputs=None,
1626
  outputs=[analytics_display],
1627
+ js="() => { return confirm('Tem certeza que deseja resetar TODOS os dados de analytics e cache? Esta ação não pode ser desfeita.') }"
1628
  )
1629
 
1630
  # Lançar aplicação