1. 增加了本地模型的检测接口
This commit is contained in:
@@ -155,3 +155,37 @@ def delete_model_manage(id):
|
||||
"""删除模型"""
|
||||
generic_delete('model_manage', id)
|
||||
return jsonify({'code': 0, 'message': '删除成功'})
|
||||
|
||||
|
||||
# ============ 本地模型列表接口 ============
|
||||
|
||||
@model_manage_bp.route('/local-models', methods=['GET'])
|
||||
def get_local_models():
|
||||
"""获取本地模型列表(从YG_FT_Base/local_models目录)"""
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
# 使用 YG_FT_Base/local_models 目录
|
||||
base_path = os.path.join(PROJECT_ROOT, 'local_models')
|
||||
|
||||
models = []
|
||||
if os.path.exists(base_path):
|
||||
for item in os.listdir(base_path):
|
||||
item_path = os.path.join(base_path, item)
|
||||
if os.path.isdir(item_path):
|
||||
models.append({
|
||||
'name': item,
|
||||
'path': item_path
|
||||
})
|
||||
|
||||
return jsonify({
|
||||
'code': 0,
|
||||
'data': {
|
||||
'models': models,
|
||||
'base_path': base_path
|
||||
}
|
||||
})
|
||||
except Exception as e:
|
||||
logger.error(f"获取本地模型列表失败: {e}")
|
||||
return jsonify({'code': 1, 'message': str(e)})
|
||||
|
||||
Reference in New Issue
Block a user