Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,26 +90,158 @@ EJEMPLO DE OUTPUT:
|
|
| 90 |
# ============================================
|
| 91 |
|
| 92 |
def build_prompt(user_text: str) -> str:
|
| 93 |
-
|
| 94 |
return SYSTEM_PROMPT_BASE + "\n\nUSER:\n" + user_text
|
| 95 |
|
| 96 |
def call_model(prompt: str) -> str:
|
| 97 |
-
|
| 98 |
-
#
|
|
|
|
| 99 |
return prompt
|
| 100 |
|
| 101 |
def infer(user_text: str) -> str:
|
|
|
|
| 102 |
prompt = build_prompt(user_text)
|
| 103 |
output = call_model(prompt)
|
| 104 |
return output
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
if __name__ == "__main__":
|
| 114 |
demo.launch()
|
| 115 |
-
|
|
|
|
| 90 |
# ============================================
|
| 91 |
|
| 92 |
def build_prompt(user_text: str) -> str:
|
| 93 |
+
"""Construye el prompt completo para el modelo."""
|
| 94 |
return SYSTEM_PROMPT_BASE + "\n\nUSER:\n" + user_text
|
| 95 |
|
| 96 |
def call_model(prompt: str) -> str:
|
| 97 |
+
"""Simulación de la llamada al modelo/API (debes sustituir esta función)."""
|
| 98 |
+
# En esta demo, devolvemos el prompt del sistema + usuario para depuración.
|
| 99 |
+
# Reemplaza esto con tu lógica de API real.
|
| 100 |
return prompt
|
| 101 |
|
| 102 |
def infer(user_text: str) -> str:
|
| 103 |
+
"""Función de inferencia principal para Gradio."""
|
| 104 |
prompt = build_prompt(user_text)
|
| 105 |
output = call_model(prompt)
|
| 106 |
return output
|
| 107 |
|
| 108 |
+
# ============================================
|
| 109 |
+
# INTERFAZ DE USUARIO CON GRADIO (MEJORADA)
|
| 110 |
+
# ============================================
|
| 111 |
+
|
| 112 |
+
def get_system_config_ui() -> str:
|
| 113 |
+
"""Genera el HTML para mostrar la configuración del sistema."""
|
| 114 |
+
specialty_html = "".join([f"<li>{s}</li>" for s in VOYEUR_SPECIALIST_CONFIG["specialties"]])
|
| 115 |
+
expertise_html = "".join([f"<li>{e}</li>" for e in VOYEUR_SPECIALIST_CONFIG["technical_expertise"]])
|
| 116 |
+
ethics_html = "".join([f"<li>{p}</li>" for p in VOYEUR_SPECIALIST_CONFIG["ethical_principles"]])
|
| 117 |
+
|
| 118 |
+
return f"""
|
| 119 |
+
<div style="background-color: #4a5568; padding: 15px; border-radius: 8px;">
|
| 120 |
+
<h3 style="color: #ffcc80;">🧠 Especialista VOYEUR</h3>
|
| 121 |
+
<p style="margin-bottom: 10px;"><strong>Rol:</strong> {VOYEUR_SPECIALIST_CONFIG['role']}</p>
|
| 122 |
+
<p style="margin-bottom: 15px;"><strong>Modelo:</strong> {VOYEUR_SPECIALIST_CONFIG['name']}</p>
|
| 123 |
+
|
| 124 |
+
<h4 style="color: #ffcc80;">📝 Especialidades</h4>
|
| 125 |
+
<ul style="list-style-type: disc; margin-left: 20px;">{specialty_html}</ul>
|
| 126 |
+
|
| 127 |
+
<h4 style="color: #ffcc80;">🛠️ Experiencia Técnica</h4>
|
| 128 |
+
<ul style="list-style-type: disc; margin-left: 20px;">{expertise_html}</ul>
|
| 129 |
+
|
| 130 |
+
<h4 style="color: #ffcc80;">📚 Elementos de Contexto</h4>
|
| 131 |
+
<p><strong>Profesiones:</strong> {professions_str}...</p>
|
| 132 |
+
<p><strong>Lencería:</strong> {thongs_str}...</p>
|
| 133 |
+
</div>
|
| 134 |
+
<div style="margin-top: 15px; padding: 15px; border-radius: 8px; border: 1px solid #ff7043;">
|
| 135 |
+
<h4 style="color: #ff7043;">📜 Principios Éticos (NO EXPLÍCITO)</h4>
|
| 136 |
+
<ul style="list-style-type: square; margin-left: 20px;">{ethics_html}</ul>
|
| 137 |
+
</div>
|
| 138 |
+
"""
|
| 139 |
+
|
| 140 |
+
# CSS personalizado para darle un look oscuro y con detalles en naranja/dorado
|
| 141 |
+
CUSTOM_CSS = """
|
| 142 |
+
body {
|
| 143 |
+
font-family: 'Inter', sans-serif;
|
| 144 |
+
background-color: #1a1a1a;
|
| 145 |
+
}
|
| 146 |
+
.gradio-container {
|
| 147 |
+
background: #282c34;
|
| 148 |
+
border-radius: 12px;
|
| 149 |
+
padding: 20px;
|
| 150 |
+
box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7);
|
| 151 |
+
}
|
| 152 |
+
h1 {
|
| 153 |
+
color: #ff7043;
|
| 154 |
+
font-weight: 800;
|
| 155 |
+
}
|
| 156 |
+
h2 {
|
| 157 |
+
color: #e0e0e0;
|
| 158 |
+
}
|
| 159 |
+
button {
|
| 160 |
+
background-color: #ff7043 !important;
|
| 161 |
+
color: white !important;
|
| 162 |
+
border-radius: 10px !important;
|
| 163 |
+
font-weight: bold;
|
| 164 |
+
transition: all 0.3s;
|
| 165 |
+
}
|
| 166 |
+
button:hover {
|
| 167 |
+
background-color: #e65100 !important;
|
| 168 |
+
box-shadow: 0 4px 15px rgba(255, 112, 67, 0.4);
|
| 169 |
+
}
|
| 170 |
+
.main-panel {
|
| 171 |
+
background-color: #333842;
|
| 172 |
+
padding: 20px;
|
| 173 |
+
border-radius: 12px;
|
| 174 |
+
}
|
| 175 |
+
"""
|
| 176 |
+
|
| 177 |
+
with gr.Blocks(css=CUSTOM_CSS, title="Voyeur Prompt Generator") as demo:
|
| 178 |
+
|
| 179 |
+
# Fila Principal para el Título
|
| 180 |
+
with gr.Row():
|
| 181 |
+
# Etiqueta de firma "BATUTO-ART" (pequeña y dorada)
|
| 182 |
+
gr.HTML(
|
| 183 |
+
"""
|
| 184 |
+
<div style="position: absolute; top: 10px; left: 15px; z-index: 10;">
|
| 185 |
+
<span style="font-family: cursive; font-size: 1.2em; color: #FFD700; text-shadow: 1px 1px 2px #000; letter-spacing: 1px;">
|
| 186 |
+
BATUTO-ART
|
| 187 |
+
</span>
|
| 188 |
+
</div>
|
| 189 |
+
"""
|
| 190 |
+
)
|
| 191 |
+
gr.Markdown(
|
| 192 |
+
"""
|
| 193 |
+
<div style="text-align: center; padding-top: 20px;">
|
| 194 |
+
<h1>🖼️ Generador de Prompts VOYEUR</h1>
|
| 195 |
+
<p style="color: #ffcc80; font-size: 1.1em; margin-bottom: 20px;">
|
| 196 |
+
Tu Maestro de Prompting Hiperrealista y Sensual.
|
| 197 |
+
<br/>¡Siempre artístico, nunca explícito!
|
| 198 |
+
</p>
|
| 199 |
+
</div>
|
| 200 |
+
"""
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
with gr.Row(equal_height=True):
|
| 204 |
+
# COLUMNA IZQUIERDA: Configuración del Sistema
|
| 205 |
+
with gr.Column(scale=1, min_width=300):
|
| 206 |
+
with gr.Accordion("⚙️ Configuración del Especialista", open=False):
|
| 207 |
+
gr.HTML(get_system_config_ui())
|
| 208 |
+
|
| 209 |
+
gr.Markdown(
|
| 210 |
+
"""
|
| 211 |
+
## Instrucciones Rápidas
|
| 212 |
+
<ul style="list-style-type: none; padding-left: 0;">
|
| 213 |
+
<li>1. Describe la <strong style="color: #ffcc80;">escena</strong> (ej: cocina, biblioteca).</li>
|
| 214 |
+
<li>2. Indica la <strong style="color: #ffcc80;">acción</strong> (ej: agachándose, estirándose).</li>
|
| 215 |
+
<li>3. Menciona <strong style="color: #ffcc80;">profesión</strong> o <strong style="color: #ffcc80;">vestimenta</strong> (ej: abogada, medias de seda).</li>
|
| 216 |
+
</ul>
|
| 217 |
+
"""
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
# COLUMNA DERECHA: Interacción Principal
|
| 221 |
+
with gr.Column(scale=2, min_width=400, css_classes=["main-panel"]):
|
| 222 |
+
|
| 223 |
+
gr.Markdown("### 💬 Escribe tu visión fotográfica")
|
| 224 |
+
|
| 225 |
+
inp = gr.Textbox(
|
| 226 |
+
label="Instrucciones del usuario (Español)",
|
| 227 |
+
lines=4,
|
| 228 |
+
placeholder="Ej: Quiero una foto de una sommelier muy elegante con medias de red ajustándose el liguero en el sótano de una bodega antigua."
|
| 229 |
+
)
|
| 230 |
+
|
| 231 |
+
btn = gr.Button("✨ Generar Prompt VOYEUR ✨", size="lg")
|
| 232 |
+
|
| 233 |
+
gr.Markdown("### 📜 Prompt de Output (Exclusivamente en Inglés)")
|
| 234 |
+
|
| 235 |
+
out = gr.Textbox(
|
| 236 |
+
label="Output del Modelo (Prompt para Generador de Imágenes)",
|
| 237 |
+
lines=8,
|
| 238 |
+
placeholder="El prompt de alta calidad aparecerá aquí...",
|
| 239 |
+
show_copy_button=True
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
# Enlazar la función al botón
|
| 243 |
+
btn.click(fn=infer, inputs=inp, outputs=out)
|
| 244 |
|
| 245 |
if __name__ == "__main__":
|
| 246 |
demo.launch()
|
| 247 |
+
|