Release/v0.2.2 (#260)

* [modify] migration script

* [add] migration script

* fix(web): change form message

* fix(web): the memoryContent field is compatible with numbers and strings

* feat(web): code node hidden

* fix(model):
1. create a basic model to check if the name and provider are duplicated.
2. The result shows error models because the provider created API Keys for all matching models.

---------

Co-authored-by: Mark <zhuwenhui5566@163.com>
Co-authored-by: zhaoying <yzhao96@best-inc.com>
Co-authored-by: yingzhao <zhaoyingyz@126.com>
Co-authored-by: Timebomb2018 <18868801967@163.com>
This commit is contained in:
Ke Sun
2026-01-30 15:10:22 +08:00
committed by GitHub
parent f1503b2238
commit e7370489e8
7 changed files with 132 additions and 33 deletions

View File

@@ -630,6 +630,13 @@ class ModelBaseRepository:
db.add(model_base)
return model_base
@staticmethod
def get_by_name_and_provider(db: Session, name: str, provider: str) -> Optional['ModelBase']:
return db.query(ModelBase).filter(
ModelBase.name == name,
ModelBase.provider == provider
).first()
@staticmethod
def update(db: Session, model_base_id: uuid.UUID, data: dict) -> Optional['ModelBase']:
model_base = db.query(ModelBase).filter(ModelBase.id == model_base_id).first()

View File

@@ -508,10 +508,7 @@ class ModelApiKeyService:
)
if not validation_result["valid"]:
# 记录验证失败的模型,但不抛出异常
failed_models.append({
"model_name": model_name,
"error": validation_result["error"]
})
failed_models.append(model_name)
continue
# 创建API Key
@@ -692,6 +689,9 @@ class ModelBaseService:
@staticmethod
def create_model_base(db: Session, data: model_schema.ModelBaseCreate):
existing = ModelBaseRepository.get_by_name_and_provider(db, data.name, data.provider)
if existing:
raise BusinessException("模型已存在", BizCode.DUPLICATE_NAME)
model_base = ModelBaseRepository.create(db, data.model_dump())
db.commit()
db.refresh(model_base)