Atualizar app/app.py

This commit is contained in:
2026-08-19 21:50:14 -03:00
parent 1fba14078a
commit 43544c4c22
+20 -12
View File
@@ -862,7 +862,7 @@ def vision(cid):
# ===========
# 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"])
@login_required
@@ -878,20 +878,28 @@ def import_excel(cid):
temp_path = f"/data/{uuid.uuid4()}.{ext}"
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()
msg = Message(
id=str(uuid.uuid4()),
conversation_id=cid,
role="user",
content=f"```\n{tsv}\n```"
)
db.add(msg)
db.commit()
db.close()
# Each sheet becomes a separate TSV message
for sheet_name, tsv in sheets.items():
msg = Message(
id=str(uuid.uuid4()),
conversation_id=cid,
role="user",
content=f"### Sheet: {sheet_name}\n```\n{tsv}\n```"
)
db.add(msg)
# return jsonify({"status": "ok"})
return jsonify({"status": "ok", "sheets": list(sheets.keys())})
return jsonify({"status": "ok"})
# ================