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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +117 -93
app.py CHANGED
@@ -8,24 +8,24 @@ def generar_diagnostico(tipo_proyecto, objetivo, foto, nombre, telefono, descrip
8
  objetivo = objetivo or "No especificado"
9
  descripcion = descripcion or "Sin descripción adicional"
10
 
11
- analisis_foto = "Análisis espectral de imagen: Completado. Sustrato listo para verificación." if foto else "Sin evidencia visual cargada."
12
 
13
- informe_ui = f"""🔬 EN CONSTRUCCIÓN LAB · INFORME TÉCNICO PRELIMINAR
14
  ======================================================
15
- [REGISTRO]: LAB-MED-{urllib.parse.quote(nombre[:3].upper())}
16
 
17
- ► MATRIZ DE PROYECTO: {tipo_proyecto}
18
- ► OBJETIVO DETECTADO: {objetivo}
19
- ► ESTADO CLÍNICO: Listo para asignación de ingeniero de campo.
20
  ► SOLICITANTE: {nombre}
21
 
22
- ► EVIDENCIA VISUAL:
23
  {analisis_foto}
24
 
25
- ► DIAGNÓSTICO ADICIONAL:
26
  "{descripcion}"
27
  ======================================================
28
- SISTEMA CORE · CONSTRUFULL MEDELLÍN SAS"""
29
 
30
  mensaje_wa = f"""*DIAGNÓSTICO ESPACIAL: LAB* 🧪
31
  _EN CONSTRUCCIÓN LAB | Operaciones_
@@ -35,21 +35,19 @@ _EN CONSTRUCCIÓN LAB | Operaciones_
35
  🏗️ *Proyecto:* {tipo_proyecto}
36
  🎯 *Objetivo:* {objetivo}
37
 
38
- 📝 *Descripción del Entorno:*
39
  "{descripcion}"
40
-
41
- 🔬 _Evidencia fotográfica adjunta en el servidor de origen._
42
  ---
43
- ⚙️ _Despachado desde el motor de análisis digital_"""
44
 
45
  mensaje_codificado = urllib.parse.quote(mensaje_wa)
46
  link = f"https://wa.me/573233476985?text={mensaje_codificado}"
47
 
48
  boton_html = f"""
49
- <div style="text-align:center; padding:20px; margin: 10px auto; max-width: 450px;">
50
  <a href="{link}" target="_blank" style="text-decoration: none;">
51
  <button class="btn-whatsapp-premium">
52
- 📲 TRANSMITIR DIAGNÓSTICO A WHATSAPP
53
  </button>
54
  </a>
55
  </div>
@@ -58,154 +56,180 @@ _EN CONSTRUCCIÓN LAB | Operaciones_
58
  return informe_ui, boton_html
59
 
60
 
61
- # Inyección de CSS Ultra-Interactivo (Haciendo los radio botones "juguetones" y táctiles)
62
  custom_css = """
63
- body, .gradio-container { background-color: #0B0F19 !important; color: #E2E8F0 !important; }
64
- .tabs, .box, .input-container, input, textarea, select { background-color: #111827 !important; border: 1px solid #1F2937 !important; color: white !important; }
65
- label { color: #38BDF8 !important; font-weight: bold !important; font-family: monospace !important; letter-spacing: 1px; margin-bottom: 8px; }
66
- .markdown-text h1 { color: #FFFFFF !important; font-weight: 800; }
67
- .markdown-text h3 { color: #38BDF8 !important; font-family: monospace; border-bottom: 1px dashed #1F2937; padding-bottom: 5px; }
68
- footer { display: none !important; }
 
 
 
 
 
 
 
 
69
 
70
- /* 🎮 TRANSFORMACIÓN JUGUETONA DE LOS BOTONES RADIO (TARJETAS 3D INTERACTIVAS) */
 
 
 
 
 
 
 
 
 
71
  .gradio-container .gr-input-label {
72
- background: #1E293B !important;
73
- border: 2px solid #334155 !important;
74
  border-radius: 12px !important;
75
- padding: 16px !important;
76
- margin: 6px 0 !important;
77
  cursor: pointer !important;
 
 
78
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
79
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
80
  }
81
 
82
- /* Efecto Hover: Al pasar el mouse se levanta y brilla */
83
  .gradio-container .gr-input-label:hover {
84
- transform: translateY(-3px) scale(1.02) !important;
85
  border-color: #38BDF8 !important;
86
- background: #0F172A !important;
87
- box-shadow: 0 10px 20px -5px rgba(56, 189, 248, 0.2) !important;
88
  }
89
 
90
- /* Estado Seleccionado: El botón cambia radicalmente indicando activación */
91
- .gradio-container .gr-input-label[data-selected="true"],
92
- .gradio-container input[type="radio"]:checked + span {
93
- background: linear-gradient(135deg, #1E1B4B 0%, #0F172A 100%) !important;
94
- border-color: #38BDF8 !important;
95
- box-shadow: 0 0 15px rgba(56, 189, 248, 0.4) !important;
96
- animation: pulse-border 1.5s infinite alternate;
97
  }
98
 
99
- /* Botón Principal de Procesar */
100
  button.primary {
101
- background: #111827 !important;
102
  border: 2px solid #F59E0B !important;
103
  color: #F59E0B !important;
104
- font-weight: bold !important;
 
105
  letter-spacing: 2px !important;
106
  border-radius: 10px !important;
107
- padding: 15px !important;
108
- transition: all 0.3s ease !important;
 
109
  }
110
  button.primary:hover {
111
  background: #F59E0B !important;
112
- color: #0B0F19 !important;
113
- transform: scale(1.03);
114
- box-shadow: 0 0 20px rgba(245, 158, 11, 0.4) !important;
115
  }
116
 
117
- /* Botón Final de WhatsApp Animado */
118
  .btn-whatsapp-premium {
119
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
120
  color: white;
121
  border: none;
122
- padding: 18px 36px;
123
- font-size: 16px;
124
  font-weight: bold;
125
- letter-spacing: 1px;
126
- border-radius: 50px;
127
  cursor: pointer;
128
  width: 100%;
129
- box-shadow: 0px 8px 20px rgba(37, 211, 102, 0.4);
130
- transition: all 0.3s ease;
131
  }
132
  .btn-whatsapp-premium:hover {
133
- transform: translateY(-2px) scale(1.03);
134
- box-shadow: 0px 12px 25px rgba(37, 211, 102, 0.6);
135
  }
136
 
137
- @keyframes pulse-border {
138
- from { box-shadow: 0 0 10px rgba(56, 189, 248, 0.3); }
139
- to { box-shadow: 0 0 20px rgba(56, 189, 248, 0.6); }
140
- }
141
  """
142
 
143
  with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as demo:
144
 
145
  gr.Markdown("""
146
- # 🧪 EN CONSTRUCCIÓN LAB
147
- ### *Spatial Transformation & Diagnostic Engine* • Una marca de CONSTRUFULL MEDELLÍN SAS
148
 
149
  ---
 
150
  """)
151
 
 
152
  with gr.Row():
 
 
153
  with gr.Column(scale=1):
154
- gr.Markdown("### FASE 1 · ¿QUÉ ESPACIO DESEAS INTERVENIR?")
155
  tipo_proyecto = gr.Radio(
156
  choices=[
157
- "🛁 Módulo Baño",
158
- "🍳 Módulo Cocina",
159
- "🏠 Estructura Completa",
160
- "🏢 Entorno Comercial",
161
- "✨ Área Microcemento",
162
- "🏗️ Obra Nueva"
163
  ],
164
- label="Selecciona un componente de la cuadrícula:",
165
  show_label=False
166
  )
167
 
168
- gr.Markdown("### FASE 2 · ¿CUÁL ES EL OBJETIVO CLÍNICO?")
169
  objetivo = gr.Radio(
170
  choices=[
171
- "✨ Modernización Estética",
172
- "🔧 Reparación de Patologías",
173
- "📈 Maximizar Valorización",
174
- "🏢 Adecuación Operativa",
175
- "🔥 Reconfiguración Total"
176
  ],
177
- label="Selecciona la meta del laboratorio:",
178
  show_label=False
179
  )
180
 
 
181
  with gr.Column(scale=1):
182
- gr.Markdown("### FASE 3 · REGISTRO FOTOGRÁFICO")
183
  foto = gr.Image(
184
- label="Cargar evidencia visual para escáner (Opcional)",
185
  type="filepath"
186
  )
187
 
188
- gr.Markdown("### FASE 4 · DATOS DE AUDITORÍA")
189
- nombre = gr.Textbox(label="Identificación del Solicitante", placeholder="Ej. Juan Pérez")
190
- telefono = gr.Textbox(label="Línea de WhatsApp de Enlace", placeholder="Ej. 3233476985")
191
  descripcion = gr.Textbox(
192
- label="Notas de Campo / Observaciones",
193
- placeholder="Describe brevemente lo que imaginas o los daños del lugar...",
194
- lines=3
195
  )
196
 
197
- boton_ejecutar = gr.Button("🧱 EJECUTAR PROTOCOLO DE ANÁLISIS", variant="primary")
 
198
 
199
  gr.Markdown("---")
200
 
201
- informe_salida = gr.Textbox(
202
- label="[SISTEMA LAB] REPORTE TÉCNICO GENERADO",
203
- lines=8,
204
- interactive=False
205
- )
206
-
207
- whatsapp_salida = gr.HTML()
 
 
 
 
208
 
 
209
  boton_ejecutar.click(
210
  fn=generar_diagnostico,
211
  inputs=[tipo_proyecto, objetivo, foto, nombre, telefono, descripcion],
 
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_
 
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>
 
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],