mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-13 12:49:30 +00:00
feat(mcp): 重构 MCP 服务器及智能助手模块
- 新增代码生成模块路由支持 - 重构 MCP 服务器API,支持增删改查接口和分页查询 - 实现 MCP 智能对话的流式响应和 WebSocket 通信 - 优化 MCP 数据模型,支持环境变量等配置项 - 改进 MCP CRUD 层,集成权限控制和统一操作方法 - 优化异常处理,提升接口错误信息准确性 - 修正依赖导入和数据校验,增强代码健壮性
This commit is contained in:
@@ -8,23 +8,13 @@ import psutil
|
||||
from datetime import datetime
|
||||
from typing import List, Dict, Any, Optional
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import UploadFile
|
||||
from PIL import Image
|
||||
|
||||
# 尝试导入 magic 库,如果失败则标记为不可用
|
||||
try:
|
||||
import magic
|
||||
MAGIC_AVAILABLE = True
|
||||
except ImportError:
|
||||
MAGIC_AVAILABLE = False
|
||||
import pylibmagic # 不要删除,否则import magic 导入启动报错ImportError: failed to find libmagic. Check your installation
|
||||
import magic
|
||||
|
||||
from app.core.exceptions import CustomException
|
||||
from app.core.logger import logger
|
||||
|
||||
# 如果 magic 不可用,记录日志
|
||||
if not MAGIC_AVAILABLE:
|
||||
logger.info("没有找到 python-magic 库,将使用基于扩展名的文件类型检测")
|
||||
from app.utils.excel_util import ExcelUtil
|
||||
from app.config.setting import settings
|
||||
from ...module_system.auth.schema import AuthSchema
|
||||
@@ -116,7 +106,7 @@ class ResourceService:
|
||||
|
||||
# 优先使用 magic 库检测 MIME 类型
|
||||
file_type = None
|
||||
if MAGIC_AVAILABLE and os.path.isfile(safe_path):
|
||||
if os.path.isfile(safe_path):
|
||||
try:
|
||||
file_type = magic.from_file(safe_path, mime=True)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user