Atualizar app/app.py
This commit is contained in:
+33
@@ -400,6 +400,39 @@ def synthesize(cid):
|
||||
return send_file(path, mimetype="audio/mpeg", as_attachment=False)
|
||||
|
||||
|
||||
from PIL import Image
|
||||
|
||||
@app.route("/api/vision/<cid>", methods=["POST"])
|
||||
@login_required
|
||||
@require_capability("can_use_vision")
|
||||
def vision(cid):
|
||||
file = request.files.get("file")
|
||||
if not file:
|
||||
return jsonify({"error": "No image"}), 400
|
||||
|
||||
img_id = str(uuid.uuid4())
|
||||
path = f"/data/img-{img_id}.png"
|
||||
file.save(path)
|
||||
|
||||
# Here you would call a vision-capable model (pseudo-code).
|
||||
# description = call_vision_model(path)
|
||||
|
||||
description = "Image description placeholder"
|
||||
|
||||
db = SessionLocal()
|
||||
msg = Message(
|
||||
id=str(uuid.uuid4()),
|
||||
conversation_id=cid,
|
||||
role="assistant",
|
||||
content=description,
|
||||
)
|
||||
db.add(msg)
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
return jsonify({"status": "ok", "description": description})
|
||||
|
||||
|
||||
# ***
|
||||
|
||||
import json
|
||||
|
||||
Reference in New Issue
Block a user