Skip to content

Commit

Permalink
Fix session API issues. (infiniflow#3939)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
KevinHuSh authored Dec 9, 2024
1 parent afe82fe commit 255f4cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/apps/sdk/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,14 @@ def chatbot_completions(dialog_id):
req["quote"] = False

if req.get("stream", True):
resp = Response(iframe_completion(objs[0].tenant_id, dialog_id, **req), mimetype="text/event-stream")
resp = Response(iframe_completion(dialog_id, **req), mimetype="text/event-stream")
resp.headers.add_header("Cache-control", "no-cache")
resp.headers.add_header("Connection", "keep-alive")
resp.headers.add_header("X-Accel-Buffering", "no")
resp.headers.add_header("Content-Type", "text/event-stream; charset=utf-8")
return resp

for answer in agent_completion(objs[0].tenant_id, dialog_id, **req):
for answer in iframe_completion(dialog_id, **req):
return get_result(data=answer)


Expand Down
2 changes: 2 additions & 0 deletions api/db/services/canvas_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def completion(tenant_id, agent_id, question, session_id=None, stream=True, **kw
assert e, "Session not found!"
canvas = Canvas(json.dumps(conv.dsl), tenant_id)

if not conv.message:
conv.message = []
messages = conv.message
question = {
"role": "user",
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 @@ -176,6 +176,8 @@ def iframe_completion(dialog_id, question, session_id=None, stream=True, **kwarg
e, conv = API4ConversationService.get_by_id(session_id)
assert e, "Session not found!"

if not conv.message:
conv.message = []
messages = conv.message
question = {
"role": "user",
Expand Down

0 comments on commit 255f4cc

Please sign in to comment.