Fix session API issues. (#3939)

### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu 2024-12-09 17:37:36 +08:00 committed by GitHub
parent afe82feb57
commit 255f4ccffc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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",

View File

@ -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",