mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-02 01:27:14 +00:00
feat(core): Upgrade pydantic to 2.x (#1428)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# Define your Pydantic schemas here
|
||||
from dbgpt._private.pydantic import BaseModel, Field
|
||||
from typing import Any, Dict
|
||||
|
||||
from dbgpt._private.pydantic import BaseModel, ConfigDict, Field, model_to_dict
|
||||
|
||||
from ..config import SERVE_APP_NAME_HUMP
|
||||
|
||||
@@ -9,13 +11,20 @@ class ServeRequest(BaseModel):
|
||||
|
||||
# TODO define your own fields here
|
||||
|
||||
class Config:
|
||||
title = f"ServeRequest for {SERVE_APP_NAME_HUMP}"
|
||||
model_config = ConfigDict(title=f"ServeRequest for {SERVE_APP_NAME_HUMP}")
|
||||
|
||||
def to_dict(self, **kwargs) -> Dict[str, Any]:
|
||||
"""Convert the model to a dictionary"""
|
||||
return model_to_dict(self, **kwargs)
|
||||
|
||||
|
||||
class ServerResponse(BaseModel):
|
||||
"""{__template_app_name__hump__} response model"""
|
||||
|
||||
# TODO define your own fields here
|
||||
class Config:
|
||||
title = f"ServerResponse for {SERVE_APP_NAME_HUMP}"
|
||||
|
||||
model_config = ConfigDict(title=f"ServerResponse for {SERVE_APP_NAME_HUMP}")
|
||||
|
||||
def to_dict(self, **kwargs) -> Dict[str, Any]:
|
||||
"""Convert the model to a dictionary"""
|
||||
return model_to_dict(self, **kwargs)
|
||||
|
@@ -41,7 +41,9 @@ class ServeDao(BaseDao[ServeEntity, ServeRequest, ServerResponse]):
|
||||
Returns:
|
||||
T: The entity
|
||||
"""
|
||||
request_dict = request.dict() if isinstance(request, ServeRequest) else request
|
||||
request_dict = (
|
||||
request.to_dict() if isinstance(request, ServeRequest) else request
|
||||
)
|
||||
entity = ServeEntity(**request_dict)
|
||||
# TODO implement your own logic here, transfer the request_dict to an entity
|
||||
return entity
|
||||
|
Reference in New Issue
Block a user