Atualizar app/app.py

This commit is contained in:
2026-08-19 21:50:14 -03:00
parent 1fba14078a
commit 43544c4c22
+14 -6
View File
@@ -862,7 +862,7 @@ def vision(cid):
# =========== # ===========
# IO # IO
from io_excel import convert_excel from io.excel import convert_excel, convert_excel_all_sheets
@app.route("/api/import_excel/<cid>", methods=["POST"]) @app.route("/api/import_excel/<cid>", methods=["POST"])
@login_required @login_required
@@ -878,20 +878,28 @@ def import_excel(cid):
temp_path = f"/data/{uuid.uuid4()}.{ext}" temp_path = f"/data/{uuid.uuid4()}.{ext}"
file.save(temp_path) file.save(temp_path)
tsv = convert_excel(temp_path) # tsv = convert_excel(temp_path)
# Convert all sheets
sheets = convert_excel_all_sheets(temp_path)
db = SessionLocal() db = SessionLocal()
# Each sheet becomes a separate TSV message
for sheet_name, tsv in sheets.items():
msg = Message( msg = Message(
id=str(uuid.uuid4()), id=str(uuid.uuid4()),
conversation_id=cid, conversation_id=cid,
role="user", role="user",
content=f"```\n{tsv}\n```" content=f"### Sheet: {sheet_name}\n```\n{tsv}\n```"
) )
db.add(msg) db.add(msg)
db.commit()
db.close()
return jsonify({"status": "ok"}) # return jsonify({"status": "ok"})
return jsonify({"status": "ok", "sheets": list(sheets.keys())})
# ================ # ================