Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -3420,6 +3420,7 @@ def crear_app():
|
|
| 3420 |
return gr.update(choices=listado)
|
| 3421 |
|
| 3422 |
categorias_mass_state_pmt = gr.State(value=[]) # Estado para almacenar categorías disponibles
|
|
|
|
| 3423 |
categorias_mass_pmt = gr.Dropdown(
|
| 3424 |
choices=categorias_mass_state_pmt.value, multiselect=False, label="Categorías"#, info="Selecciona una categoria para aplicar el filtro."
|
| 3425 |
)
|
|
@@ -3434,11 +3435,25 @@ def crear_app():
|
|
| 3434 |
elementos = df[categoria].dropna().unique().tolist()
|
| 3435 |
# return ", ".join(elementos)
|
| 3436 |
return gr.update(choices=elementos)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3437 |
|
| 3438 |
# filtro_categoria_state = gr.State(value=[]) # Estado para almacenar categorías seleccionadas para filtro
|
| 3439 |
filtro_categoria_pmt= gr.Dropdown(
|
| 3440 |
choices=[], multiselect=True, interactive=True, label="Elementos de categoría", info="Selecciona una o varias opciones para aplicar el análisis."
|
| 3441 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3442 |
|
| 3443 |
bttn_filtro_categoria_pmt = gr.Button("Aplicar filtro por categoría", variant="secondary")
|
| 3444 |
|
|
@@ -3478,8 +3493,57 @@ def crear_app():
|
|
| 3478 |
plot_mass_metas_pmt = gr.Plot(label="Ranking Global METAS")
|
| 3479 |
with gr.Column(scale=1):
|
| 3480 |
exp_mass_metas_pmt = gr.Markdown()
|
| 3481 |
-
|
| 3482 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3483 |
with gr.Tab("MASIVA CON PROMPTING", visible=False):
|
| 3484 |
gr.Markdown("Aquí puedes processar múltiples iniciativas con enfoque de prompting. (Usa la plantilla proporcionada)")
|
| 3485 |
|
|
|
|
| 3420 |
return gr.update(choices=listado)
|
| 3421 |
|
| 3422 |
categorias_mass_state_pmt = gr.State(value=[]) # Estado para almacenar categorías disponibles
|
| 3423 |
+
iniciativas_pmt = gr.State(value=[])
|
| 3424 |
categorias_mass_pmt = gr.Dropdown(
|
| 3425 |
choices=categorias_mass_state_pmt.value, multiselect=False, label="Categorías"#, info="Selecciona una categoria para aplicar el filtro."
|
| 3426 |
)
|
|
|
|
| 3435 |
elementos = df[categoria].dropna().unique().tolist()
|
| 3436 |
# return ", ".join(elementos)
|
| 3437 |
return gr.update(choices=elementos)
|
| 3438 |
+
|
| 3439 |
+
def listar_iniciativas(file):
|
| 3440 |
+
if file is None: # or categoria not in file.columns:
|
| 3441 |
+
return "No hay datos disponibles"
|
| 3442 |
+
df = pd.read_excel(file)
|
| 3443 |
+
if 'iniciativa' not in df.columns:
|
| 3444 |
+
return f"No se encontró 'iniciativa' en el archivo"
|
| 3445 |
+
elementos = df['iniciativa'].dropna().unique().tolist()
|
| 3446 |
+
# return ", ".join(elementos)
|
| 3447 |
+
return gr.update(choices=elementos)
|
| 3448 |
|
| 3449 |
# filtro_categoria_state = gr.State(value=[]) # Estado para almacenar categorías seleccionadas para filtro
|
| 3450 |
filtro_categoria_pmt= gr.Dropdown(
|
| 3451 |
choices=[], multiselect=True, interactive=True, label="Elementos de categoría", info="Selecciona una o varias opciones para aplicar el análisis."
|
| 3452 |
)
|
| 3453 |
+
|
| 3454 |
+
file_output.change(listar_iniciativas,
|
| 3455 |
+
file_output,
|
| 3456 |
+
iniciativas_pmt)
|
| 3457 |
|
| 3458 |
bttn_filtro_categoria_pmt = gr.Button("Aplicar filtro por categoría", variant="secondary")
|
| 3459 |
|
|
|
|
| 3493 |
plot_mass_metas_pmt = gr.Plot(label="Ranking Global METAS")
|
| 3494 |
with gr.Column(scale=1):
|
| 3495 |
exp_mass_metas_pmt = gr.Markdown()
|
|
|
|
| 3496 |
|
| 3497 |
+
|
| 3498 |
+
## AJUSTE POR FILTROS DE CATEGORIA
|
| 3499 |
+
with gr.Column():
|
| 3500 |
+
bttn_filtro_categoria.click(
|
| 3501 |
+
fn=lambda df, categoria, elementos: df[df[categoria].isin(elementos)] if df is not None else None,
|
| 3502 |
+
inputs=[base_ods_mass_mix, categorias_mass, filtro_categoria],
|
| 3503 |
+
outputs=[base_ods_mass_mix_cat]
|
| 3504 |
+
)
|
| 3505 |
+
|
| 3506 |
+
bttn_filtro_categoria.click(
|
| 3507 |
+
fn=lambda df, categoria, elementos: df[df[categoria].isin(elementos)] if df is not None else None,
|
| 3508 |
+
inputs=[base_meta_mass_mix, categorias_mass, filtro_categoria],
|
| 3509 |
+
outputs=[base_meta_mass_mix_cat]
|
| 3510 |
+
)
|
| 3511 |
+
|
| 3512 |
+
bttn_filtro_categoria.click(
|
| 3513 |
+
fn=lambda df, categoria, elementos: df[df[categoria].isin(elementos)] if df is not None else None,
|
| 3514 |
+
inputs=[base_indicadores_mass_mix, categorias_mass, filtro_categoria],
|
| 3515 |
+
outputs=[base_indicadores_mass_mix_cat]
|
| 3516 |
+
)
|
| 3517 |
+
|
| 3518 |
+
base_ods_mass_mix_cat.change(
|
| 3519 |
+
fn=tab_viz19,
|
| 3520 |
+
inputs=[base_ods_mass_mix_cat, base_meta_mass_mix_cat, base_indicadores_mass_mix_cat],
|
| 3521 |
+
outputs=[html19_1, html19_2, html19_3, exp19]
|
| 3522 |
+
)
|
| 3523 |
+
|
| 3524 |
+
base_meta_mass_mix_cat.change(
|
| 3525 |
+
fn=tab_viz19,
|
| 3526 |
+
inputs=[base_ods_mass_mix_cat, base_meta_mass_mix_cat, base_indicadores_mass_mix_cat],
|
| 3527 |
+
outputs=[html19_1, html19_2, html19_3, exp19]
|
| 3528 |
+
)
|
| 3529 |
+
|
| 3530 |
+
base_indicadores_mass_mix_cat.change(
|
| 3531 |
+
fn=tab_viz19,
|
| 3532 |
+
inputs=[base_ods_mass_mix_cat, base_meta_mass_mix_cat, base_indicadores_mass_mix_cat],
|
| 3533 |
+
outputs=[html19_1, html19_2, html19_3, exp19]
|
| 3534 |
+
)
|
| 3535 |
+
|
| 3536 |
+
|
| 3537 |
+
|
| 3538 |
+
# btn_mass_emb.click(
|
| 3539 |
+
# fn=procesar_archivo,
|
| 3540 |
+
# inputs=[file_output],
|
| 3541 |
+
# outputs=[output_ods_mass, output_meta_mass, output_indicadores_mass,categorias_mass_state, msj_procesamiento_mass],
|
| 3542 |
+
# show_progress=True
|
| 3543 |
+
# )
|
| 3544 |
+
|
| 3545 |
+
btn_mass_emb_pmt.click(procesar_lote_llm, iniciativas_pmt, [base_ods_mass_mix_pmt,base_meta_mass_mix_pmt,base_indicadores_mass_mix_pmt], show_progress=True)
|
| 3546 |
+
|
| 3547 |
with gr.Tab("MASIVA CON PROMPTING", visible=False):
|
| 3548 |
gr.Markdown("Aquí puedes processar múltiples iniciativas con enfoque de prompting. (Usa la plantilla proporcionada)")
|
| 3549 |
|