Atualizar app/app.py
This commit is contained in:
+20
-12
@@ -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()
|
||||||
msg = Message(
|
# Each sheet becomes a separate TSV message
|
||||||
id=str(uuid.uuid4()),
|
for sheet_name, tsv in sheets.items():
|
||||||
conversation_id=cid,
|
msg = Message(
|
||||||
role="user",
|
id=str(uuid.uuid4()),
|
||||||
content=f"```\n{tsv}\n```"
|
conversation_id=cid,
|
||||||
)
|
role="user",
|
||||||
db.add(msg)
|
content=f"### Sheet: {sheet_name}\n```\n{tsv}\n```"
|
||||||
db.commit()
|
)
|
||||||
db.close()
|
db.add(msg)
|
||||||
|
|
||||||
|
# return jsonify({"status": "ok"})
|
||||||
|
return jsonify({"status": "ok", "sheets": list(sheets.keys())})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return jsonify({"status": "ok"})
|
|
||||||
|
|
||||||
|
|
||||||
# ================
|
# ================
|
||||||
|
|||||||
Reference in New Issue
Block a user