之前存在106.52上的仓库被重新初始化了,同时增加了测试账号的兼容,测试账号hxbtest001,...hxbtest005
This commit is contained in:
@@ -115,7 +115,7 @@ def update(tenant_id, chat_id, session_id):
|
||||
@token_required
|
||||
def completion(tenant_id, chat_id): # chat_id 和 别的文件中的dialog_id 应该是一个意思? cyx 2025-01-25
|
||||
req = request.json
|
||||
logging.info(f"/chats/{chat_id}/completions--0 req={req}") # cyx
|
||||
#logging.info(f"/chats/{chat_id}/completions--0 req={req}") # cyx
|
||||
if not req.get("session_id"): # session_id 和 别的文件中的conversation_id 应该是一个意思? cyx 2025-01-25
|
||||
conv = {
|
||||
"id": get_uuid(),
|
||||
@@ -130,6 +130,17 @@ def completion(tenant_id, chat_id): # chat_id 和 别的文件中的dialog_id
|
||||
session_id = conv.id
|
||||
else:
|
||||
session_id = req.get("session_id")
|
||||
# 2025 0423 cyx 修改,前端传入的session_id ,但数据库库中可能不存在,需要创建
|
||||
conv_exist = ConversationService.query(id=session_id, dialog_id=chat_id)
|
||||
if not conv_exist: # session_id 的对话在数据库中不存在 # 当 conv_exist 为 None、空列表 []、空元组 () 等时进入此分支
|
||||
conv = {
|
||||
"id": session_id,
|
||||
"dialog_id": chat_id,
|
||||
"name": req.get("name", "New session"),
|
||||
"message": [{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}]
|
||||
}
|
||||
ConversationService.save(**conv)
|
||||
#-------------------------------------
|
||||
if not req.get("question"):
|
||||
return get_error_data_result(message="Please input your question.")
|
||||
|
||||
@@ -148,6 +159,7 @@ def completion(tenant_id, chat_id): # chat_id 和 别的文件中的dialog_id
|
||||
if not conv:
|
||||
return get_error_data_result(message="Session does not exist")
|
||||
conv = conv[0]
|
||||
#logging.info(f"/chats/{chat_id}/completions--4 history_limit={history_limit} conv={conv.message}") # cyx
|
||||
if not DialogService.query(id=chat_id, tenant_id=tenant_id, status=StatusEnum.VALID.value):
|
||||
return get_error_data_result(message="You do not own the chat")
|
||||
msg = []
|
||||
@@ -172,7 +184,6 @@ def completion(tenant_id, chat_id): # chat_id 和 别的文件中的dialog_id
|
||||
current_assistant_count += 1
|
||||
continue
|
||||
msg.append(m)
|
||||
|
||||
message_id = msg[-1].get("id")
|
||||
e, dia = DialogService.get_by_id(conv.dialog_id)
|
||||
logging.info(f"/chats/{chat_id}/completions req={req}--dale --2 history_limit={history_limit} dia {dia}") # cyx
|
||||
|
||||
Reference in New Issue
Block a user