Update app.py
Browse files
app.py
CHANGED
@@ -334,24 +334,33 @@ def evaluate(texto: str, model_key: str):
|
|
334 |
# CSV helper
|
335 |
# ==========================
|
336 |
def make_csv_from_table(table: dict) -> str:
|
|
|
337 |
cols = table.get("columns", [])
|
338 |
rows = table.get("data", [])
|
339 |
-
model_key = table.get("model_key", "")
|
340 |
-
model_id = table.get("model_id", "")
|
341 |
-
|
342 |
-
# Armamos encabezados con 2 columnas al inicio
|
343 |
-
header_out = ["Modelo (etiqueta)", "Modelo (repo)"] + cols
|
344 |
-
|
345 |
ts = int(time.time())
|
346 |
path = f"/tmp/icb4_leadership_{ts}.csv"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
with open(path, "w", newline="", encoding="utf-8") as f:
|
348 |
writer = csv.writer(f)
|
349 |
-
writer.writerow(
|
350 |
for r in rows:
|
351 |
-
writer.writerow(
|
|
|
352 |
return path if os.path.exists(path) else ""
|
353 |
|
354 |
|
|
|
355 |
# ==========================
|
356 |
# UI (2 columnas + selector modelo + CSV)
|
357 |
# ==========================
|
|
|
334 |
# CSV helper
|
335 |
# ==========================
|
336 |
def make_csv_from_table(table: dict) -> str:
|
337 |
+
"""Genera CSV temporal sin incluir la columna 'Modelo (repo)'."""
|
338 |
cols = table.get("columns", [])
|
339 |
rows = table.get("data", [])
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
ts = int(time.time())
|
341 |
path = f"/tmp/icb4_leadership_{ts}.csv"
|
342 |
+
|
343 |
+
# Si existe la columna 'Modelo (repo)', la eliminamos
|
344 |
+
if "Modelo (repo)" in cols:
|
345 |
+
idx = cols.index("Modelo (repo)")
|
346 |
+
cols = [c for c in cols if c != "Modelo (repo)"]
|
347 |
+
new_rows = []
|
348 |
+
for r in rows:
|
349 |
+
if len(r) > idx:
|
350 |
+
r = r[:idx] + r[idx + 1:]
|
351 |
+
new_rows.append(r)
|
352 |
+
rows = new_rows
|
353 |
+
|
354 |
with open(path, "w", newline="", encoding="utf-8") as f:
|
355 |
writer = csv.writer(f)
|
356 |
+
writer.writerow(cols)
|
357 |
for r in rows:
|
358 |
+
writer.writerow(r)
|
359 |
+
|
360 |
return path if os.path.exists(path) else ""
|
361 |
|
362 |
|
363 |
+
|
364 |
# ==========================
|
365 |
# UI (2 columnas + selector modelo + CSV)
|
366 |
# ==========================
|