update sql表名

This commit is contained in:
朱潮 2026-01-30 00:03:26 +08:00
parent f88aca74f2
commit 51f988e535
2 changed files with 38 additions and 14 deletions

View File

@ -164,36 +164,60 @@ async def list_files(path: str = "", recursive: bool = False):
async def upload_file(file: UploadFile = File(...), path: str = Form("")):
"""
上传文件
Args:
file: 上传的文件
path: 目标路径相对于支持目录
path: 目标路径相对于支持目录如果不存在会自动创建
"""
try:
target_path = resolve_path(path) if path else resolve_path("projects")
if not target_path.exists() or not target_path.is_dir():
# 如果没有指定路径,默认使用 projects 目录
if not path:
target_path = resolve_path("projects")
else:
# 验证路径格式是否合法(必须以支持的目录开头)
path_parts = Path(path).parts
if not path_parts or path_parts[0] not in SUPPORTED_DIRECTORIES:
raise HTTPException(
status_code=400,
detail=f"路径必须以以下目录之一开头: {', '.join(SUPPORTED_DIRECTORIES)}"
)
# 直接构建路径,不检查是否存在(稍后会创建)
target_path = PROJECTS_DIR / path
# 如果目标路径已存在且是文件,则使用其父目录
if target_path.exists() and target_path.is_file():
target_path = target_path.parent
# 创建目标目录(包括所有不存在的父目录)
target_path.mkdir(parents=True, exist_ok=True)
file_path = target_path / file.filename
# 如果文件已存在,检查是否覆盖
if file_path.exists():
# 可以添加版本控制或重命名逻辑
pass
with open(file_path, "wb") as buffer:
content = await file.read()
buffer.write(content)
# 计算返回的相对路径
try:
relative_path = file_path.relative_to(PROJECTS_DIR)
except ValueError:
relative_path = file_path
return {
"success": True,
"message": "文件上传成功",
"filename": file.filename,
"path": str(Path(path) / file.filename),
"path": str(relative_path),
"size": len(content)
}
except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=f"文件上传失败: {str(e)}")

View File

@ -465,7 +465,7 @@ async def fetch_bot_config_from_db(bot_user_id: str) -> Dict[str, Any]:
async with conn.cursor() as cursor:
# 首先根据 bot_user_id 查找 bot 的 UUID
await cursor.execute(
"SELECT id, name FROM bots WHERE bot_id = %s",
"SELECT id, name FROM agent_bots WHERE bot_id = %s",
(bot_user_id,)
)
bot_row = await cursor.fetchone()
@ -484,7 +484,7 @@ async def fetch_bot_config_from_db(bot_user_id: str) -> Dict[str, Any]:
SELECT model_id,
language, robot_type, dataset_ids, system_prompt, user_identifier,
enable_memori, tool_response, skills
FROM bot_settings WHERE bot_id = %s
FROM agent_bot_settings WHERE bot_id = %s
""",
(bot_uuid,)
)
@ -521,7 +521,7 @@ async def fetch_bot_config_from_db(bot_user_id: str) -> Dict[str, Any]:
await cursor.execute(
"""
SELECT model, server, api_key
FROM models WHERE id = %s
FROM agent_models WHERE id = %s
""",
(model_id,)
)
@ -570,7 +570,7 @@ async def fetch_bot_config_from_db(bot_user_id: str) -> Dict[str, Any]:
await cursor.execute(
"""
SELECT name, type, config, enabled
FROM mcp_servers WHERE bot_id = %s AND enabled = true
FROM agent_mcp_servers WHERE bot_id = %s AND enabled = true
""",
(bot_uuid,)
)