construfull commited on
Commit
cc05330
·
verified ·
1 Parent(s): 233f364

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +139 -163
app.py CHANGED
@@ -1,237 +1,213 @@
1
  import gradio as gr
2
  import urllib.parse
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- def generar_diagnostico(tipo_proyecto, objetivo, foto, nombre, telefono, descripcion):
5
- nombre = nombre or "Explorador LAB"
6
- telefono = telefono or "No especificado"
7
- tipo_proyecto = tipo_proyecto or "No especificado"
8
- objetivo = objetivo or "No especificado"
9
- descripcion = descripcion or "Sin descripción adicional"
10
-
11
- analisis_foto = "Análisis espectral de imagen: Completado. Matriz de pixeles lista." if foto else "Sin evidencia visual cargada."
12
-
13
- informe_ui = f"""🔬 EN CONSTRUCCIÓN LAB · REPORTE TÉCNICO
14
  ======================================================
15
- [CÓDIGO SISTEMA]: LAB-MED-{urllib.parse.quote(nombre[:3].upper())}
 
16
 
17
- ► COMPONENTE: {tipo_proyecto}
18
- ► META CLÍNICA: {objetivo}
19
- ► ESTADO: Configurado. Listo para asignación de ingeniería.
20
- ► SOLICITANTE: {nombre}
21
 
22
- ► DIAGNÓSTICO ÓPTICO:
23
- {analisis_foto}
24
-
25
- ► OBSERVACIONES:
26
- "{descripcion}"
27
  ======================================================
28
- DIVISIÓN TECNOLÓGICA · CONSTRUFULL MEDELLÍN SAS"""
 
 
 
 
29
 
30
- mensaje_wa = f"""*DIAGNÓSTICO ESPACIAL: LAB* 🧪
31
- _EN CONSTRUCCIÓN LAB | Operaciones_
 
 
32
 
33
- 👤 *Cliente:* {nombre}
34
- 📞 *WhatsApp:* {telefono}
35
- 🏗️ *Proyecto:* {tipo_proyecto}
36
- 🎯 *Objetivo:* {objetivo}
37
 
38
- 📝 *Notas de Campo:*
39
- "{descripcion}"
40
  ---
41
- ⚙️ _Despachado desde el motor digital_"""
42
 
43
  mensaje_codificado = urllib.parse.quote(mensaje_wa)
44
  link = f"https://wa.me/573233476985?text={mensaje_codificado}"
45
 
46
- boton_html = f"""
47
- <div style="text-align:center; padding:10px; margin: 5px auto; max-width: 450px;">
48
- <a href="{link}" target="_blank" style="text-decoration: none;">
49
- <button class="btn-whatsapp-premium">
50
- 📲 TRANSMITIR DATOS A UN INGENIERO VIA WHATSAPP
51
- </button>
52
- </a>
 
 
 
 
 
 
 
53
  </div>
54
  """
55
 
56
- return informe_ui, boton_html
57
 
58
 
59
- # 🔥 EL "MAQUILLAJE" REVOLUCIONARIO DE LA APP (CSS Avanzado para Hugging Face)
60
  custom_css = """
61
- /* Fondo general estilo laboratorio oscuro (Tesla / Figma) */
62
- body, .gradio-container {
63
- background-color: #070A13 !important;
64
- color: #E2E8F0 !important;
65
- font-family: 'Inter', system-ui, sans-serif !important;
66
- }
67
 
68
- /* Contenedores y cajas de texto */
69
- .tabs, .box, .input-container, input, textarea, select {
70
- background-color: #0F172A !important;
71
- border: 1px solid #1E293B !important;
72
- color: white !important;
73
- border-radius: 8px !important;
74
- }
75
-
76
- /* Títulos de las fases con estética de código */
77
- label {
78
- color: #38BDF8 !important;
79
- font-weight: bold !important;
80
- font-family: monospace !important;
81
- letter-spacing: 1.5px;
82
- text-transform: uppercase;
83
- }
84
-
85
- /* 🎮 REDISEÑO TOTAL DE LOS BOTONES RADIO A TARJETAS INTERACTIVAS JUGUETONAS */
86
  .gradio-container .gr-input-label {
87
- background: #111827 !important;
88
  border: 2px solid #1F2937 !important;
89
- border-radius: 12px !important;
90
- padding: 18px 14px !important;
91
- margin: 8px 0 !important;
92
- cursor: pointer !important;
93
- display: flex !important;
94
- align-items: center !important;
95
- transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
96
  }
97
-
98
- /* Efecto hover (Al pasar el cursor o presionar con el dedo) */
99
  .gradio-container .gr-input-label:hover {
100
- transform: translateY(-4px) scale(1.015) !important;
101
- border-color: #38BDF8 !important;
102
- background: #1E293B !important;
103
- box-shadow: 0 12px 20px -5px rgba(56, 189, 248, 0.25) !important;
104
  }
105
 
106
- /* Ocultar el círculo nativo feo del radio button para que parezca una app real */
107
- .gradio-container input[type="radio"] {
108
- accent-color: #38BDF8 !important;
109
- transform: scale(1.2) !important;
110
- margin-right: 12px !important;
111
- }
112
-
113
- /* Botón central de Procesamiento estilo Industrial */
114
  button.primary {
115
- background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%) !important;
116
- border: 2px solid #F59E0B !important;
117
- color: #F59E0B !important;
118
  font-weight: 900 !important;
119
- font-family: monospace !important;
120
- letter-spacing: 2px !important;
121
- border-radius: 10px !important;
122
- padding: 16px !important;
123
- box-shadow: 0 4px 15px rgba(245, 158, 11, 0.1) !important;
124
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
125
  }
126
  button.primary:hover {
127
- background: #F59E0B !important;
128
- color: #070A13 !important;
129
- transform: translateY(-2px);
130
- box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4) !important;
131
  }
132
 
133
- /* Botón de salida a WhatsApp Premium */
134
- .btn-whatsapp-premium {
135
- background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  color: white;
137
  border: none;
138
- padding: 16px 24px;
139
- font-size: 15px;
140
  font-weight: bold;
141
- letter-spacing: 0.5px;
142
- border-radius: 8px;
143
  cursor: pointer;
144
  width: 100%;
145
- box-shadow: 0px 6px 18px rgba(37, 211, 102, 0.3);
146
- transition: all 0.2s ease;
147
- }
148
- .btn-whatsapp-premium:hover {
149
- transform: scale(1.02);
150
- box-shadow: 0px 10px 22px rgba(37, 211, 102, 0.5);
151
  }
 
152
 
153
  footer { display: none !important; }
154
  """
155
 
156
  with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as demo:
157
 
 
158
  gr.Markdown("""
159
- # 🧪 EN CONSTRUCCIÓN | LAB
160
- ### *Spatial Transformation & Diagnostic Engine* • CONSTRUFULL MEDELLÍN SAS
161
-
162
  ---
163
- **ESTADO DEL SISTEMA:** Módulos de análisis clínico listos. Diseña tu espacio abajo.
164
  """)
165
 
166
- # 🧱 DISEÑO DE DOS COLUMNAS DE ALTA FIDELIDAD
167
  with gr.Row():
168
-
169
- # COLUMNA 1: CONFIGURACIÓN FÍSICA
170
  with gr.Column(scale=1):
171
- gr.Markdown("### FASE 1 · OBJETO DE TRANSFORMACIÓN")
172
  tipo_proyecto = gr.Radio(
173
- choices=[
174
- "🛁 Módulo Baño Premium",
175
- "🍳 Módulo Cocina Avanzada",
176
- "🏠 Estructura / Vivienda Completa",
177
- "🏢 Entorno Comercial / Negocio",
178
- "✨ Superficie en Microcemento",
179
- "🏗️ Obra Nueva y Ampliación"
180
- ],
181
- label="Selecciona la matriz a intervenir",
182
- show_label=False
183
  )
184
 
185
- gr.Markdown("### FASE 2 · OBJETIVO CLÍNICO")
186
  objetivo = gr.Radio(
187
- choices=[
188
- "✨ Modernización y Alta Estética",
189
- "🔧 Reparación de Patologías Estructurales",
190
- "📈 Maximizar Valorización Inmobiliaria",
191
- "🏢 Adecuación Operativa Comercial",
192
- "🔥 Reconfiguración Arquitectónica Total"
193
- ],
194
- label="Selecciona la meta del proyecto",
195
- show_label=False
196
  )
197
 
198
- # COLUMNA 2: AUDITORÍA Y EVIDENCIA
199
  with gr.Column(scale=1):
200
- gr.Markdown("### FASE 3 · REGISTRO ÓPTICO")
201
- foto = gr.Image(
202
- label="Cargar evidencia fotográfica para escáner (Opcional)",
203
- type="filepath"
204
- )
205
-
206
- gr.Markdown("### FASE 4 · CREDENCIALES DEL SOLICITANTE")
207
- nombre = gr.Textbox(label="Identificación / Nombre Completo", placeholder="Ej. Juan Pérez")
208
- telefono = gr.Textbox(label="Línea de Enlace WhatsApp", placeholder="Ej. 3233476985")
209
- descripcion = gr.Textbox(
210
- label="Notas de Campo Adicionales",
211
- placeholder="Describe brevemente las patologías, daños o ideas para el espacio...",
212
- lines=4
213
- )
214
-
215
- # ACCIÓN CENTRAL
216
- boton_ejecutar = gr.Button("🧱 COMPILAR Y EJECUTAR DIAGNÓSTICO", variant="primary")
217
 
218
  gr.Markdown("---")
219
 
220
- # RESULTADOS
221
  with gr.Row():
222
  with gr.Column(scale=1):
223
  informe_salida = gr.Textbox(
224
- label="[CONSOLA SYSTEM] REPORTE ENCRIPTADO GENERADO",
225
- lines=9,
226
  interactive=False
227
  )
228
  with gr.Column(scale=1):
229
- gr.Markdown("<br><br>") # Espaciador visual para alinear el botón de WhatsApp
230
  whatsapp_salida = gr.HTML()
231
 
232
- # EJECUCIÓN DEL FLUJO CONECTANDO TODOS LOS COMPONENTES
233
  boton_ejecutar.click(
234
- fn=generar_diagnostico,
235
  inputs=[tipo_proyecto, objetivo, foto, nombre, telefono, descripcion],
236
  outputs=[informe_salida, whatsapp_salida]
237
  )
 
1
  import gradio as gr
2
  import urllib.parse
3
+ import time
4
+
5
+ def ejecutar_protocolo_shanghai(tipo_proyecto, objetivo, foto, nombre, telefono, descripcion):
6
+ if not nombre or not telefono:
7
+ return (
8
+ "🚨 [ERROR DE AUTENTICACIÓN] Por favor ingresa Nombre y WhatsApp para activar el escáner.",
9
+ "<div style='text-align:center; color:#EF4444;'>Falta información de contacto.</div>"
10
+ )
11
+
12
+ # 🏎️ SIMULACIÓN DE PROCESAMIENTO ASIÁTICO (Genera el efecto WOW de espera técnica)
13
+ time.sleep(2.5)
14
+
15
+ # Lógica de cálculo dinámico "juguetón" estilo app china
16
+ material_estimado = "85 kg de Microcemento Nanotech + Base Polimérica" if "Microcemento" in tipo_proyecto else "Kits de Anclaje Estructural + Aditivos"
17
+ if "Baño" in tipo_proyecto: material_estimado = "Sistemas de Impermeabilización Avanzada + Acabados Epóxicos"
18
+ if "Cocina" in tipo_proyecto: material_estimado = "Módulos de Alta Resistencia Térmica y Superficies de Cuarzo"
19
 
20
+ # Consola técnica para la interfaz
21
+ informe_ui = f"""⚡ EN CONSTRUCCIÓN LAB · AUTOMATION TOKYO-ENGINE
 
 
 
 
 
 
 
 
22
  ======================================================
23
+ [NIVEL DE USUARIO]: S-RANK CONSTRUCTOR 🔥
24
+ [ID PROYECTO]: CN-MED-{int(time.time())}
25
 
26
+ ► MATRIZ SELECCIONADA: {tipo_proyecto}
27
+ ► VECTOR DE OPERACIÓN: {objetivo}
28
+ ► CÁLCULO DE MATERIALES PREDICTIVO:
29
+ {material_estimado}
30
 
31
+ ► ESTADO GLOBAL: ¡PROCESADO CON ÉXITO!
 
 
 
 
32
  ======================================================
33
+ ¡Felicidades {nombre}! Has desbloqueado un beneficio exclusivo."""
34
+
35
+ # Mensaje persuasivo y ultra-comercial para WhatsApp
36
+ mensaje_wa = f"""*¡ALERTA DE PROYECTO PREMIUM - EN CONSTRUCCIÓN LAB!* 🧪🔥
37
+ _Ecosistema de Conversión Rápida de Construfull_
38
 
39
+ 👤 *Constructor:* {nombre}
40
+ 📞 *Línea Directa:* {telefono}
41
+ 📐 *Matriz:* {tipo_proyecto}
42
+ 🎯 *Meta:* {objetivo}
43
 
44
+ 📦 *Sustratos e Insumos Estimados:*
45
+ _{material_estimado}_
 
 
46
 
47
+ 🎁 *RECOMPENSA ACTIVA:* Ha reclamado el *Bono de Auditoría Express* + Muestra Física de Microcemento en ExpoCamaCol.
 
48
  ---
49
+ 🚀 _Enviado desde el Laboratorio del Futuro_"""
50
 
51
  mensaje_codificado = urllib.parse.quote(mensaje_wa)
52
  link = f"https://wa.me/573233476985?text={mensaje_codificado}"
53
 
54
+ # RECOMPENSA ESTILO CUUPÓN CHINO (Llamativo, con urgencia y botones de acción)
55
+ cupon_html = f"""
56
+ <div class="china-coupon-card">
57
+ <div class="coupon-left">
58
+ <h2>RECOMPENSA</h2>
59
+ <p>CONSTRUFULL SAS</p>
60
+ </div>
61
+ <div class="coupon-right">
62
+ <h3>AUDITORÍA TÉCNICA 100% GRATIS</h3>
63
+ <p style="color: #94A3B8; font-size: 11px;">Válido por las próximas 2 horas para {nombre}</p>
64
+ <a href="{link}" target="_blank" style="text-decoration: none;">
65
+ <button class="btn-china-claim">🎯 RECLAMAR BENEFICIO EN WHATSAPP</button>
66
+ </a>
67
+ </div>
68
  </div>
69
  """
70
 
71
+ return informe_ui, cupon_html
72
 
73
 
74
+ # 🧧 CSS AL ESTILO SUPER-APP (Neón, Contraste Alto, Efectos Táctiles Masivos)
75
  custom_css = """
76
+ body, .gradio-container { background-color: #060814 !important; color: #F1F5F9 !important; font-family: 'Inter', sans-serif !important; }
77
+ .tabs, .box, .input-container, input, textarea, select { background-color: #0B0F19 !important; border: 2px solid #1E293B !important; color: white !important; }
78
+ label { color: #10B981 !important; font-weight: 900 !important; font-family: monospace !important; font-size: 13px !important; }
 
 
 
79
 
80
+ /* 🎮 CASILLAS DE SELECCIÓN GAMIFICADAS */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  .gradio-container .gr-input-label {
82
+ background: linear-gradient(135deg, #111827 0%, #0F172A 100%) !important;
83
  border: 2px solid #1F2937 !important;
84
+ border-radius: 14px !important;
85
+ padding: 16px !important;
86
+ font-weight: bold !important;
87
+ transition: all 0.2s ease-in-out !important;
 
 
 
88
  }
 
 
89
  .gradio-container .gr-input-label:hover {
90
+ border-color: #10B981 !important; /* Verde Neón de éxito financiero */
91
+ transform: scale(1.03) !important;
92
+ background: #064E3B !important;
93
+ box-shadow: 0 0 15px rgba(16, 185, 129, 0.3) !important;
94
  }
95
 
96
+ /* BOTÓN DE DISPARO INMEDIATO */
 
 
 
 
 
 
 
97
  button.primary {
98
+ background: linear-gradient(90deg, #F59E0B 0%, #EF4444 100%) !important; /* Degradado de energía asiático */
99
+ border: none !important;
100
+ color: white !important;
101
  font-weight: 900 !important;
102
+ font-size: 16px !important;
103
+ letter-spacing: 1px !important;
104
+ border-radius: 50px !important;
105
+ padding: 18px !important;
106
+ box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4) !important;
 
107
  }
108
  button.primary:hover {
109
+ transform: translateY(-2px) scale(1.02);
110
+ box-shadow: 0 6px 25px rgba(239, 68, 68, 0.6) !important;
 
 
111
  }
112
 
113
+ /* 🧧 DISEÑO DEL CUPÓN CHINO DE CONVERSIÓN RÁPIDA */
114
+ .china-coupon-card {
115
+ display: flex;
116
+ background: #111827;
117
+ border: 2px dashed #EF4444;
118
+ border-radius: 12px;
119
+ overflow: hidden;
120
+ max-width: 500px;
121
+ margin: 15px auto;
122
+ box-shadow: 0 10px 25px rgba(239, 68, 68, 0.15);
123
+ }
124
+ .coupon-left {
125
+ background: linear-gradient(135deg, #EF4444 0%, #991B1B 100%);
126
+ color: white;
127
+ padding: 20px;
128
+ display: flex;
129
+ flex-direction: column;
130
+ justify-content: center;
131
+ align-items: center;
132
+ min-width: 130px;
133
+ }
134
+ .coupon-left h2 { margin: 0; font-size: 18px; font-weight: 900; letter-spacing: 1px; }
135
+ .coupon-left p { margin: 5px 0 0 0; font-size: 10px; opacity: 0.8; font-family: monospace; }
136
+ .coupon-right {
137
+ padding: 20px;
138
+ text-align: left;
139
+ flex-grow: 1;
140
+ display: flex;
141
+ flex-direction: column;
142
+ justify-content: center;
143
+ }
144
+ .coupon-right h3 { margin: 0; color: #10B981; font-size: 16px; font-weight: 800; }
145
+ .btn-china-claim {
146
+ background: #10B981;
147
  color: white;
148
  border: none;
149
+ padding: 10px 15px;
 
150
  font-weight: bold;
151
+ border-radius: 6px;
 
152
  cursor: pointer;
153
  width: 100%;
154
+ margin-top: 10px;
155
+ transition: background 0.2s;
 
 
 
 
156
  }
157
+ .btn-china-claim:hover { background: #059669; }
158
 
159
  footer { display: none !important; }
160
  """
161
 
162
  with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as demo:
163
 
164
+ # Banner superior estilo transmisión en vivo / Gamificado
165
  gr.Markdown("""
166
+ # 🧪 EN CONSTRUCCIÓN | INTERACTIVE LAB
167
+ ### 🚀 PROTOCOLO ACELERADO DE TRANSFORMACIÓN · CONSTRUFULL MEDELLÍN SAS
 
168
  ---
169
+ 🔴 **USUARIOS ACTIVOS EN MEDELLÍN:** 42 diagnosticando ahora mismo... ¡Completa el tuyo y asegura beneficios!
170
  """)
171
 
 
172
  with gr.Row():
 
 
173
  with gr.Column(scale=1):
174
+ gr.Markdown("### [PASO 01] SELECCIONA EL NÚCLEO DE LA OBRA")
175
  tipo_proyecto = gr.Radio(
176
+ choices=["🛁 Módulo Baño Inteligente", "🍳 Módulo Cocina de Lujo", "✨ Superficie de Microcemento", "🏢 Rediseño Comercial Completo"],
177
+ label="Matriz de Entrada", show_label=False
 
 
 
 
 
 
 
 
178
  )
179
 
180
+ gr.Markdown("### [PASO 02] DEFINE EL IMPACTO")
181
  objetivo = gr.Radio(
182
+ choices=["✨ Estética Disruptiva", "🔧 Reparación y Diagnóstico Clínico", "📈 Multiplicar Valor de Reventa"],
183
+ label="Impacto del Algoritmo", show_label=False
 
 
 
 
 
 
 
184
  )
185
 
 
186
  with gr.Column(scale=1):
187
+ gr.Markdown("### [PASO 03] REGISTRO Y MONITOREO")
188
+ foto = gr.Image(label="Escanear Espacio Actual (Opcional)", type="filepath")
189
+
190
+ nombre = gr.Textbox(label="Tu Nombre (Para asignar el Bono)", placeholder="Ej. Carlos Mendoza")
191
+ telefono = gr.Textbox(label="WhatsApp de Enlace Inmediato", placeholder="Ej. 3001234567")
192
+ descripcion = gr.Textbox(label="Especificaciones Técnicas Libres", placeholder="Añade detalles especiales aquí...", lines=2)
193
+
194
+ # El gran botón asiático de conversión masiva
195
+ boton_ejecutar = gr.Button("⚡ COMPILAR DATOS Y RECLAMAR PREMIO ⚡", variant="primary")
 
 
 
 
 
 
 
 
196
 
197
  gr.Markdown("---")
198
 
 
199
  with gr.Row():
200
  with gr.Column(scale=1):
201
  informe_salida = gr.Textbox(
202
+ label="🖥️ CORE CONSOLE (ALGORITMO PREDICTIVO DE MATERIALES)",
203
+ lines=8,
204
  interactive=False
205
  )
206
  with gr.Column(scale=1):
 
207
  whatsapp_salida = gr.HTML()
208
 
 
209
  boton_ejecutar.click(
210
+ fn=ejecutar_protocolo_shanghai,
211
  inputs=[tipo_proyecto, objetivo, foto, nombre, telefono, descripcion],
212
  outputs=[informe_salida, whatsapp_salida]
213
  )