mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 03:16:51 +08:00
improve: mordernizing validation by migrating pydantic from 1.x to 2.x (#4592)
This commit is contained in:
@@ -2,7 +2,7 @@ from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
from flask import current_app
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from core.entities.model_entities import ModelWithProviderEntity, ProviderModelWithStatusEntity
|
||||
from core.entities.provider_entities import QuotaConfiguration
|
||||
@@ -61,6 +61,9 @@ class ProviderResponse(BaseModel):
|
||||
custom_configuration: CustomConfigurationResponse
|
||||
system_configuration: SystemConfigurationResponse
|
||||
|
||||
# pydantic configs
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
def __init__(self, **data) -> None:
|
||||
super().__init__(**data)
|
||||
|
||||
@@ -139,6 +142,9 @@ class DefaultModelResponse(BaseModel):
|
||||
model_type: ModelType
|
||||
provider: SimpleProviderEntityResponse
|
||||
|
||||
# pydantic configs
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
||||
class ModelWithProviderEntityResponse(ModelWithProviderEntity):
|
||||
"""
|
||||
@@ -147,4 +153,4 @@ class ModelWithProviderEntityResponse(ModelWithProviderEntity):
|
||||
provider: SimpleProviderEntityResponse
|
||||
|
||||
def __init__(self, model: ModelWithProviderEntity) -> None:
|
||||
super().__init__(**model.dict())
|
||||
super().__init__(**model.model_dump())
|
||||
|
||||
Reference in New Issue
Block a user