[changes] From the perspective of logical judgment, to determine the situation of duplicate names

This commit is contained in:
lanceyq
2026-03-05 18:59:23 +08:00
parent d052c31ac5
commit c3707f543c
5 changed files with 45 additions and 12 deletions

View File

@@ -115,6 +115,17 @@ class DataConfigService: # 数据配置服务类PostgreSQL
# --- Create ---
def create(self, params: ConfigParamsCreate) -> Dict[str, Any]: # 创建配置参数(仅名称与描述)
# 业务层检查同一工作空间下是否已存在同名配置
if params.workspace_id and params.config_name:
from app.models.memory_config_model import MemoryConfig
existing = (
self.db.query(MemoryConfig)
.filter_by(workspace_id=params.workspace_id, config_name=params.config_name)
.first()
)
if existing:
raise ValueError(f"DUPLICATE_CONFIG_NAME:{params.config_name}")
# 如果workspace_id存在且模型字段未全部指定则自动获取
if params.workspace_id and not all([params.llm_id, params.embedding_id, params.rerank_id]):
configs = self._get_workspace_configs(params.workspace_id)