之前存在106.52上的仓库被重新初始化了,同时增加了测试账号的兼容,测试账号hxbtest001,...hxbtest005

This commit is contained in:
qcloud
2025-09-01 20:09:26 +08:00
parent e6644a5262
commit 8d90798647
16 changed files with 25420 additions and 157 deletions

View File

@@ -286,21 +286,26 @@ def upload_file(tenant_id,mesum_id):
if parsed_json_res.get('success') is True:
parsed_json_data = parsed_json_res.get('data')
matchedAntiqueArray = parsed_json_data.get('antique').split(';') # 识别出的文物的数组,中间以';'分割,可能有多个
if len(matchedAntiqueArray) ==1: # 只有一个匹配项,直接返回
matchedAntiqueLabelArray = parsed_json_data.get('antique').split(';') # 识别出的文物的数组,中间以';'分割,可能有多个
if len(matchedAntiqueLabelArray) ==1: # 只有一个匹配项
logging.info(f"识别完成 得到1个{parsed_json_data.get('antique')} {labels_with_id} ")
for item in labels_with_id:
if item['label'] == parsed_json_data.get('antique'):
if is_base_same(item['label'],parsed_json_data.get('antique')):
parsed_json_data['id'] = item.get('id')
antique = {'label': item.get('label')+' '+item.get('category',''),'id':item.get('id')}
matchedArray.append(antique)
if len(matchedArray) > 1:
parsed_json_data['matchedArray'] = matchedArray
else: # 有多个匹配项,需要进行多个匹配
for label in matchedAntiqueArray[:5]:
for label in matchedAntiqueLabelArray[:5]:
antique= {'label':label}
for item in labels_with_id:
if item['label'] == label:
antique['id'] = item.get('id')
matchedArray.append(antique)
if len(matchedArray) > 0:
parsed_json_data['matchedArray'] = matchedArray
if len(matchedArray) > 0:
parsed_json_data['matchedArray'] = matchedArray
logging.info(f"{parsed_json_data}")
return jsonify({'message': 'File uploaded successfully','text': message.content,
'data': parsed_json_data}), 200
@@ -888,6 +893,9 @@ def list_objects(tenant_id,bucket: str, prefix: str = "", recursive: bool = True
except Exception as e:
return get_error_data_result(message=f"minio put list objects error {e}")
@manager.route('/get_v1_uuid', methods=['GET'])
def get_v1_uuid():
return get_result(data={"uuid":get_uuid()})
#------------------------------------------------
def audio_fade_in(audio_data, fade_length):
# 假设音频数据是16位单声道PCM
@@ -915,4 +923,28 @@ def parse_markdown_json(json_string):
# 如果解析失败,返回错误信息
return {'success': False, 'data': str(e)}
else:
return {'success': False, 'data': 'not a valid markdown json string'}
return {'success': False, 'data': 'not a valid markdown json string'}
def is_base_same(a, b):
"""
判断两个字符串是否除了尾部数字外完全相同
参数:
a, b: 要比较的两个字符串
返回:
bool: 如果基础部分相同返回True否则返回False
("陶觚", "陶觚1"), # 相同
("陶觚1", "陶觚2"), # 相同
("陶觚", "陶觚12"), # 相同
"""
# 创建正则表达式模式:匹配基础部分(忽略尾部数字)
pattern = re.compile(r'^(.*?)(?:\d*)$')
# 提取两个字符串的基础部分
base_a = pattern.match(a).group(1)
base_b = pattern.match(b).group(1)
# 比较基础部分是否相同
return base_a == base_b

View File

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