construfull commited on
Commit
b653af0
·
verified ·
1 Parent(s): 8e5785e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +103 -62
app.py CHANGED
@@ -2,17 +2,14 @@ import gradio as gr
2
  import urllib.parse
3
 
4
  def generar_diagnostico(tipo_proyecto, objetivo, foto, nombre, telefono, descripcion):
5
- # Valores por defecto por seguridad si el usuario deja campos vacíos
6
  nombre = nombre or "Explorador LAB"
7
  telefono = telefono or "No especificado"
8
  tipo_proyecto = tipo_proyecto or "No especificado"
9
  objetivo = objetivo or "No especificado"
10
  descripcion = descripcion or "Sin descripción adicional"
11
 
12
- # Verificación de evidencia visual
13
  analisis_foto = "Análisis espectral de imagen: Completado. Sustrato listo para verificación." if foto else "Sin evidencia visual cargada."
14
 
15
- # 1. Contenido para el cuadro de texto en la interfaz (Informe técnico)
16
  informe_ui = f"""🔬 EN CONSTRUCCIÓN LAB · INFORME TÉCNICO PRELIMINAR
17
  ======================================================
18
  [REGISTRO]: LAB-MED-{urllib.parse.quote(nombre[:3].upper())}
@@ -30,7 +27,6 @@ def generar_diagnostico(tipo_proyecto, objetivo, foto, nombre, telefono, descrip
30
  ======================================================
31
  SISTEMA CORE · CONSTRUFULL MEDELLÍN SAS"""
32
 
33
- # 2. Mensaje estructurado con negritas para el chat de WhatsApp
34
  mensaje_wa = f"""*DIAGNÓSTICO ESPACIAL: LAB* 🧪
35
  _EN CONSTRUCCIÓN LAB | Operaciones_
36
 
@@ -49,24 +45,11 @@ _EN CONSTRUCCIÓN LAB | Operaciones_
49
  mensaje_codificado = urllib.parse.quote(mensaje_wa)
50
  link = f"https://wa.me/573233476985?text={mensaje_codificado}"
51
 
52
- # 3. Botón interactivo premium con el look del laboratorio
53
  boton_html = f"""
54
  <div style="text-align:center; padding:20px; margin: 10px auto; max-width: 450px;">
55
  <a href="{link}" target="_blank" style="text-decoration: none;">
56
- <button style="
57
- background: linear-gradient(135deg, #38BDF8 0%, #0284C7 100%);
58
- color: white;
59
- border: none;
60
- padding: 16px 32px;
61
- font-size: 16px;
62
- font-weight: bold;
63
- letter-spacing: 1px;
64
- border-radius: 8px;
65
- cursor: pointer;
66
- width: 100%;
67
- box-shadow: 0px 4px 15px rgba(56, 189, 248, 0.4);
68
- transition: transform 0.2s ease;">
69
- 🧪 TRANSMITIR DIAGNÓSTICO A WHATSAPP
70
  </button>
71
  </a>
72
  </div>
@@ -75,15 +58,86 @@ _EN CONSTRUCCIÓN LAB | Operaciones_
75
  return informe_ui, boton_html
76
 
77
 
78
- # Inyección CSS avanzada para transformar la interfaz común en un laboratorio premium (Modo Oscuro)
79
  custom_css = """
80
  body, .gradio-container { background-color: #0B0F19 !important; color: #E2E8F0 !important; }
81
  .tabs, .box, .input-container, input, textarea, select { background-color: #111827 !important; border: 1px solid #1F2937 !important; color: white !important; }
82
- label { color: #38BDF8 !important; font-weight: bold !important; font-family: monospace !important; letter-spacing: 1px; }
83
  .markdown-text h1 { color: #FFFFFF !important; font-weight: 800; }
84
  .markdown-text h3 { color: #38BDF8 !important; font-family: monospace; border-bottom: 1px dashed #1F2937; padding-bottom: 5px; }
85
- button.primary { background: #1E293B !important; border: 1px solid #38BDF8 !important; color: #38BDF8 !important; }
86
  footer { display: none !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  """
88
 
89
  with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as demo:
@@ -93,82 +147,69 @@ with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as demo:
93
  ### *Spatial Transformation & Diagnostic Engine* • Una marca de CONSTRUFULL MEDELLÍN SAS
94
 
95
  ---
96
- **SISTEMA DE ANÁLISIS CONSTRUCTIVO v1.2** *Cargando módulos de ingeniería locativa... Listo.*
97
  """)
98
 
99
  with gr.Row():
100
- # COLUMNA IZQUIERDA: Formulario de Diagnóstico
101
  with gr.Column(scale=1):
102
- gr.Markdown("### FASE 1 · IDENTIFICACIÓN")
103
  tipo_proyecto = gr.Radio(
104
  choices=[
105
- "🛁 Baño Residencial",
106
- "🍳 Cocina Integral",
107
- "🏠 Vivienda Completa",
108
- "🏢 Local Comercial / Oficina",
109
- "✨ Superficie en Microcemento",
110
- "🏗️ Obra Nueva y Ampliación"
111
  ],
112
- label="¿Qué espacio requiere intervención?"
 
113
  )
114
 
115
- gr.Markdown("### FASE 2 · OBJETIVO PRINCIPAL")
116
  objetivo = gr.Radio(
117
  choices=[
118
- "✨ Modernizar Diseño y Acabados",
119
- "🔧 Reparar Patologías / Daños",
120
- "📈 Incrementar Valor Comercial",
121
- "🏢 Adecuar para Operación de Negocio",
122
- "🔥 Transformación Estructural Total"
123
  ],
124
- label="Meta de la intervención"
 
125
  )
126
 
127
- # COLUMNA DERECHA: Evidencia y Datos
128
  with gr.Column(scale=1):
129
- gr.Markdown("### FASE 3 · EVIDENCIA VISUAL")
130
  foto = gr.Image(
131
- label="Cargar registro fotográfico del espacio (Opcional)",
132
  type="filepath"
133
  )
134
 
135
  gr.Markdown("### FASE 4 · DATOS DE AUDITORÍA")
136
- nombre = gr.Textbox(label="Nombre del Solicitante", placeholder="Ej. Juan Pérez")
137
- telefono = gr.Textbox(label="Línea de WhatsApp", placeholder="Ej. 3233476985")
138
  descripcion = gr.Textbox(
139
- label="Notas Clínicas del Proyecto",
140
- placeholder="Cuéntanos detalles, problemas visibles o lo que imaginas para el espacio...",
141
  lines=3
142
  )
143
 
144
- # Bloque de acción y resultados
145
- boton_ejecutar = gr.Button("🚀 PROCESAR Y GENERAR DIAGNÓSTICO", variant="primary")
146
 
147
  gr.Markdown("---")
148
 
149
  informe_salida = gr.Textbox(
150
- label="[SISTEMA] REPORTE DE EVALUACIÓN GENERADO",
151
  lines=8,
152
  interactive=False
153
  )
154
 
155
  whatsapp_salida = gr.HTML()
156
 
157
- # Vinculación de eventos (Corregido metiendo la 'foto' en los inputs correspondientes)
158
  boton_ejecutar.click(
159
  fn=generar_diagnostico,
160
- inputs=[
161
- tipo_proyecto,
162
- objetivo,
163
- foto, # <-- CORREGIDO: Ahora sí se procesa la foto
164
- nombre,
165
- telefono,
166
- descripcion
167
- ],
168
- outputs=[
169
- informe_salida,
170
- whatsapp_salida
171
- ]
172
  )
173
 
174
  demo.launch()
 
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. 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())}
 
27
  ======================================================
28
  SISTEMA CORE · CONSTRUFULL MEDELLÍN SAS"""
29
 
 
30
  mensaje_wa = f"""*DIAGNÓSTICO ESPACIAL: LAB* 🧪
31
  _EN CONSTRUCCIÓN LAB | Operaciones_
32
 
 
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
  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:
 
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],
212
+ outputs=[informe_salida, whatsapp_salida]
 
 
 
 
 
 
 
 
 
 
213
  )
214
 
215
  demo.launch()