Skip to content

Commit

Permalink
Fix error message for image access. (infiniflow#3936)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

infiniflow#3883

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
KevinHuSh authored Dec 9, 2024
1 parent 044afa8 commit afe82fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions api/apps/document_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ def change_parser():
# @login_required
def get_image(image_id):
try:
arr = image_id.split("-")
if len(arr) != 2:
return get_data_error_result(message="Image not found.")
bkt, nm = image_id.split("-")
response = flask.make_response(STORAGE_IMPL.get(bkt, nm))
response.headers.set('Content-Type', 'image/JPEG')
Expand Down
13 changes: 7 additions & 6 deletions api/db/services/canvas_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import json
from uuid import uuid4
from agent.canvas import Canvas
from api.db.db_models import DB, CanvasTemplate, UserCanvas
from api.db.db_models import DB, CanvasTemplate, UserCanvas, API4Conversation
from api.db.services.api_service import API4ConversationService
from api.db.services.common_service import CommonService
from api.db.services.conversation_service import structure_answer
Expand Down Expand Up @@ -65,23 +65,24 @@ def completion(tenant_id, agent_id, question, session_id=None, stream=True, **kw
"id": session_id,
"dialog_id": cvs.id,
"user_id": kwargs.get("user_id", ""),
"message": [{"role": "assistant", "content": canvas.get_prologue()}],
"source": "agent",
"dsl": json.loads(cvs.dsl)
}
API4ConversationService.save(**conv)
yield "data:" + json.dumps({"code": 0,
if canvas.get_preset_param():
yield "data:" + json.dumps({"code": 0,
"message": "",
"data": {
"session_id": session_id,
"answer": canvas.get_prologue(),
"answer": "",
"reference": [],
"param": canvas.get_preset_param()
}
},
ensure_ascii=False) + "\n\n"
yield "data:" + json.dumps({"code": 0, "message": "", "data": True}, ensure_ascii=False) + "\n\n"
return
yield "data:" + json.dumps({"code": 0, "message": "", "data": True}, ensure_ascii=False) + "\n\n"
return
conv = API4Conversation(**conv)
else:
session_id = session_id
e, conv = API4ConversationService.get_by_id(session_id)
Expand Down
2 changes: 2 additions & 0 deletions api/db/services/conversation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def get_list(cls,dialog_id,page_number, items_per_page, orderby, desc, id , name

def structure_answer(conv, ans, message_id, session_id):
reference = ans["reference"]
if not isinstance(reference, dict):
reference = {}
temp_reference = deepcopy(ans["reference"])
if not conv.reference:
conv.reference.append(temp_reference)
Expand Down

0 comments on commit afe82fe

Please sign in to comment.