[changes]Modify the code based on the AI review
This commit is contained in:
@@ -195,6 +195,11 @@ def update_config(
|
|||||||
api_logger.warning(f"用户 {current_user.username} 尝试更新配置但未选择工作空间")
|
api_logger.warning(f"用户 {current_user.username} 尝试更新配置但未选择工作空间")
|
||||||
return fail(BizCode.INVALID_PARAMETER, "请先切换到一个工作空间", "current_workspace_id is None")
|
return fail(BizCode.INVALID_PARAMETER, "请先切换到一个工作空间", "current_workspace_id is None")
|
||||||
|
|
||||||
|
# 校验至少有一个字段需要更新
|
||||||
|
if payload.config_name is None and payload.config_desc is None and payload.scene_id is None:
|
||||||
|
api_logger.warning(f"用户 {current_user.username} 尝试更新配置但未提供任何更新字段")
|
||||||
|
return fail(BizCode.INVALID_PARAMETER, "请至少提供一个需要更新的字段", "config_name, config_desc, scene_id 均为空")
|
||||||
|
|
||||||
api_logger.info(f"用户 {current_user.username} 在工作空间 {workspace_id} 请求更新配置: {payload.config_id}")
|
api_logger.info(f"用户 {current_user.username} 在工作空间 {workspace_id} 请求更新配置: {payload.config_id}")
|
||||||
try:
|
try:
|
||||||
svc = DataConfigService(db)
|
svc = DataConfigService(db)
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ from app.services.ontology_service import OntologyService
|
|||||||
from app.core.memory.llm_tools.openai_client import OpenAIClient
|
from app.core.memory.llm_tools.openai_client import OpenAIClient
|
||||||
from app.core.memory.utils.validation.owl_validator import OWLValidator
|
from app.core.memory.utils.validation.owl_validator import OWLValidator
|
||||||
from app.services.model_service import ModelConfigService
|
from app.services.model_service import ModelConfigService
|
||||||
|
from app.repositories.ontology_scene_repository import OntologySceneRepository
|
||||||
|
|
||||||
|
|
||||||
api_logger = get_api_logger()
|
api_logger = get_api_logger()
|
||||||
@@ -785,7 +786,7 @@ async def get_scenes_simple(
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
GET /scenes/simple
|
GET /scenes/simple
|
||||||
返回: {"items": [{"scene_id": "xxx", "scene_name": "场景1"}, ...]}
|
返回: {"data": [{"scene_id": "xxx", "scene_name": "场景1"}, ...]}
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Simple scene list requested by user {current_user.id}")
|
api_logger.info(f"Simple scene list requested by user {current_user.id}")
|
||||||
|
|
||||||
@@ -795,12 +796,11 @@ async def get_scenes_simple(
|
|||||||
api_logger.warning(f"User {current_user.id} has no current workspace")
|
api_logger.warning(f"User {current_user.id} has no current workspace")
|
||||||
return fail(BizCode.BAD_REQUEST, "请求参数无效", "当前用户没有工作空间")
|
return fail(BizCode.BAD_REQUEST, "请求参数无效", "当前用户没有工作空间")
|
||||||
|
|
||||||
from app.repositories.ontology_scene_repository import OntologySceneRepository
|
|
||||||
repo = OntologySceneRepository(db)
|
repo = OntologySceneRepository(db)
|
||||||
scenes = repo.get_simple_list(workspace_id)
|
scenes = repo.get_simple_list(workspace_id)
|
||||||
|
|
||||||
api_logger.info(f"Simple scene list retrieved: {len(scenes)} scenes")
|
api_logger.info(f"Simple scene list retrieved: {len(scenes)} scenes")
|
||||||
return success(data={"items": scenes}, msg="查询成功")
|
return success(data=scenes, msg="查询成功")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(f"Failed to get simple scene list: {str(e)}", exc_info=True)
|
api_logger.error(f"Failed to get simple scene list: {str(e)}", exc_info=True)
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ class MemoryConfigRepository:
|
|||||||
if update.config_desc is not None:
|
if update.config_desc is not None:
|
||||||
db_config.config_desc = update.config_desc
|
db_config.config_desc = update.config_desc
|
||||||
has_update = True
|
has_update = True
|
||||||
if hasattr(update, 'scene_id') and update.scene_id is not None:
|
if update.scene_id is not None:
|
||||||
db_config.scene_id = update.scene_id
|
db_config.scene_id = update.scene_id
|
||||||
has_update = True
|
has_update = True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user