Spaces:
Running
Running
Update app.py
Browse filesRetificação da formatação de coluna nos estilos disponíveis
app.py
CHANGED
|
@@ -1,18 +1,14 @@
|
|
| 1 |
-
"""
|
| 2 |
# CHATBOT E GERADOR DE POSTS PARA REDES SOCIAIS
|
| 3 |
# VERSÃO COMPLETA (MERGE)
|
| 4 |
# Funcionalidades:
|
| 5 |
-
#
|
| 6 |
-
#
|
| 7 |
-
#
|
| 8 |
-
#
|
| 9 |
-
#
|
| 10 |
-
#
|
| 11 |
-
#
|
| 12 |
-
#
|
| 13 |
-
# 🚫 Copyright (c) 2025 Wilder Paz
|
| 14 |
-
# 🚫 Uso comercial proibido sem autorização expressa do autor.
|
| 15 |
-
"""
|
| 16 |
|
| 17 |
import gradio as gr
|
| 18 |
import requests
|
|
@@ -760,13 +756,11 @@ def gerar_texto(tema, nicho, estilo, formato):
|
|
| 760 |
return "❌ Erro de Configuração: API Key não está definida."
|
| 761 |
|
| 762 |
config = FORMATO_CONFIGS.get(formato, FORMATO_CONFIGS["Instagram (Post)"])
|
| 763 |
-
# ITEM 7: Buscar as instruções em inglês
|
| 764 |
instrucao_nicho = NICHOS_INSTRUCOES.get(nicho, "a general content creator") # Fallback
|
| 765 |
instrucao_estilo = ESTILOS_INSTRUCOES.get(estilo, "a clear and objective style") # Fallback
|
| 766 |
|
| 767 |
url = f"{BASE_URL}/chat/completions"
|
| 768 |
|
| 769 |
-
# ITEM 7: System prompt atualizado para incluir o estilo
|
| 770 |
system_content = f"You are {instrucao_nicho} creating a post for {formato}. Your writing style MUST be {instrucao_estilo}."
|
| 771 |
|
| 772 |
payload = {
|
|
@@ -778,7 +772,6 @@ def gerar_texto(tema, nicho, estilo, formato):
|
|
| 778 |
},
|
| 779 |
{
|
| 780 |
"role": "user",
|
| 781 |
-
# ITEM 7: Estilo removido do user prompt, pois já está no system prompt
|
| 782 |
"content": f"""Create a creative caption for {formato} about: {tema}
|
| 783 |
|
| 784 |
Requirements:
|
|
@@ -861,15 +854,15 @@ def gerar_imagem_robusta(descricao_pt, estilo_escolhido, qualidade, filtro_escol
|
|
| 861 |
configs_qualidade = {
|
| 862 |
"Rápida": {
|
| 863 |
"modelos": [MODELOS_IMAGEM[0]], # Só FLUX-schnell
|
| 864 |
-
"steps": 10
|
| 865 |
},
|
| 866 |
"Balanceada": {
|
| 867 |
"modelos": MODELOS_IMAGEM[:2], # FLUX schnell + dev
|
| 868 |
-
"steps": 25
|
| 869 |
},
|
| 870 |
"Alta": {
|
| 871 |
"modelos": MODELOS_IMAGEM, # Todos os 3
|
| 872 |
-
"steps": 30
|
| 873 |
}
|
| 874 |
}
|
| 875 |
config = configs_qualidade.get(qualidade, configs_qualidade["Balanceada"])
|
|
@@ -1222,13 +1215,13 @@ _inicializar_firestore()
|
|
| 1222 |
with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)", css=CSS) as demo:
|
| 1223 |
|
| 1224 |
gr.HTML("""
|
| 1225 |
-
<div style="background: linear-gradient(90deg, #1e3a8a, #3b82f6);
|
| 1226 |
-
<h1 style="font-size: 2.5rem; margin: 0; padding: 0; line-height: 1; display: flex; align-items: center; justify-content: center; gap: 15px;">
|
| 1227 |
<span style="font-size: 2.8rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));">🕊️</span>
|
| 1228 |
<span>Peace Chatbot</span>
|
| 1229 |
</h1>
|
| 1230 |
-
<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>
|
| 1231 |
-
<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>
|
| 1232 |
</div>
|
| 1233 |
""")
|
| 1234 |
|
|
@@ -1355,6 +1348,7 @@ with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)"
|
|
| 1355 |
editor_locked = gr.State(True)
|
| 1356 |
refinar_btn = gr.Button("✏️ Refinar Post")
|
| 1357 |
|
|
|
|
| 1358 |
gr.Markdown("ℹ️ *Use o ícone de prancheta (📋) no canto superior direito da caixa de texto para copiar o conteúdo.*")
|
| 1359 |
|
| 1360 |
with gr.Row():
|
|
|
|
|
|
|
| 1 |
# CHATBOT E GERADOR DE POSTS PARA REDES SOCIAIS
|
| 2 |
# VERSÃO COMPLETA (MERGE)
|
| 3 |
# Funcionalidades:
|
| 4 |
+
# - Geração Avançada de Imagem (Estilo, Qualidade, Filtro)
|
| 5 |
+
# - Download de Post .zip (txt + png)
|
| 6 |
+
# - Chatbot Assistente
|
| 7 |
+
# - Sistema de Cache local
|
| 8 |
+
# - Persistência de Histórico e Analytics no Firebase
|
| 9 |
+
# - Aba de Histórico com Busca, Filtros e Favoritos (em HTML colorido)
|
| 10 |
+
# - Exportar Histórico para CSV
|
| 11 |
+
# - Editor de Texto Inline
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
import gradio as gr
|
| 14 |
import requests
|
|
|
|
| 756 |
return "❌ Erro de Configuração: API Key não está definida."
|
| 757 |
|
| 758 |
config = FORMATO_CONFIGS.get(formato, FORMATO_CONFIGS["Instagram (Post)"])
|
|
|
|
| 759 |
instrucao_nicho = NICHOS_INSTRUCOES.get(nicho, "a general content creator") # Fallback
|
| 760 |
instrucao_estilo = ESTILOS_INSTRUCOES.get(estilo, "a clear and objective style") # Fallback
|
| 761 |
|
| 762 |
url = f"{BASE_URL}/chat/completions"
|
| 763 |
|
|
|
|
| 764 |
system_content = f"You are {instrucao_nicho} creating a post for {formato}. Your writing style MUST be {instrucao_estilo}."
|
| 765 |
|
| 766 |
payload = {
|
|
|
|
| 772 |
},
|
| 773 |
{
|
| 774 |
"role": "user",
|
|
|
|
| 775 |
"content": f"""Create a creative caption for {formato} about: {tema}
|
| 776 |
|
| 777 |
Requirements:
|
|
|
|
| 854 |
configs_qualidade = {
|
| 855 |
"Rápida": {
|
| 856 |
"modelos": [MODELOS_IMAGEM[0]], # Só FLUX-schnell
|
| 857 |
+
"steps": 10
|
| 858 |
},
|
| 859 |
"Balanceada": {
|
| 860 |
"modelos": MODELOS_IMAGEM[:2], # FLUX schnell + dev
|
| 861 |
+
"steps": 25
|
| 862 |
},
|
| 863 |
"Alta": {
|
| 864 |
"modelos": MODELOS_IMAGEM, # Todos os 3
|
| 865 |
+
"steps": 30
|
| 866 |
}
|
| 867 |
}
|
| 868 |
config = configs_qualidade.get(qualidade, configs_qualidade["Balanceada"])
|
|
|
|
| 1215 |
with gr.Blocks(theme=custom_theme, title="Gerador de Posts e Chatbot (Completo)", css=CSS) as demo:
|
| 1216 |
|
| 1217 |
gr.HTML("""
|
| 1218 |
+
<div style="background: linear-gradient(90deg, #1e3a8a, #3b82f6); padding: 24px; border-radius: 8px; text-align: center; margin-bottom: 10px;">
|
| 1219 |
+
<h1 style="font-size: 2.5rem; margin: 0; padding: 0; line-height: 1; display: flex; align-items: center; justify-content: center; gap: 15px; color: white;">
|
| 1220 |
<span style="font-size: 2.8rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));">🕊️</span>
|
| 1221 |
<span>Peace Chatbot</span>
|
| 1222 |
</h1>
|
| 1223 |
+
<p style="font-size: 1.2rem; margin: 12px 0 0 0; opacity: 0.9; color: white;">Gerador de Posts e Assistente de Mídias Sociais (Versão 4.1)</p>
|
| 1224 |
+
<p style="font-size: 0.9rem; margin: 4px 0 0 0; opacity: 0.8; color: white;">Desenvolvido com Hugging Face, Gradio, Llama 3.1 e Firebase</p>
|
| 1225 |
</div>
|
| 1226 |
""")
|
| 1227 |
|
|
|
|
| 1348 |
editor_locked = gr.State(True)
|
| 1349 |
refinar_btn = gr.Button("✏️ Refinar Post")
|
| 1350 |
|
| 1351 |
+
# CORREÇÃO: Removido o botão de cópia e adicionada instrução
|
| 1352 |
gr.Markdown("ℹ️ *Use o ícone de prancheta (📋) no canto superior direito da caixa de texto para copiar o conteúdo.*")
|
| 1353 |
|
| 1354 |
with gr.Row():
|