mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-09 04:49:26 +00:00
feat(core): Upgrade pydantic to 2.x (#1428)
This commit is contained in:
@@ -7,7 +7,7 @@ from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from sqlalchemy import Column, DateTime, Integer, String, Text, UniqueConstraint
|
||||
|
||||
from dbgpt._private.pydantic import BaseModel
|
||||
from dbgpt._private.pydantic import BaseModel, ConfigDict, Field, model_to_json
|
||||
from dbgpt.agent.plan.awel.team_awel_layout import AWELTeamContext
|
||||
from dbgpt.agent.resource.resource_api import AgentResource
|
||||
from dbgpt.serve.agent.team.base import TeamMode
|
||||
@@ -17,6 +17,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GptsAppDetail(BaseModel):
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
app_code: Optional[str] = None
|
||||
app_name: Optional[str] = None
|
||||
agent_name: Optional[str] = None
|
||||
@@ -28,11 +30,6 @@ class GptsAppDetail(BaseModel):
|
||||
created_at: datetime = datetime.now()
|
||||
updated_at: datetime = datetime.now()
|
||||
|
||||
class Config:
|
||||
"""Configuration for this pydantic object."""
|
||||
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
def to_dict(self):
|
||||
return {k: self._serialize(v) for k, v in self.__dict__.items()}
|
||||
|
||||
@@ -86,6 +83,8 @@ class GptsAppDetail(BaseModel):
|
||||
|
||||
|
||||
class GptsApp(BaseModel):
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
app_code: Optional[str] = None
|
||||
app_name: Optional[str] = None
|
||||
app_describe: Optional[str] = None
|
||||
@@ -100,11 +99,6 @@ class GptsApp(BaseModel):
|
||||
updated_at: datetime = datetime.now()
|
||||
details: List[GptsAppDetail] = []
|
||||
|
||||
class Config:
|
||||
"""Configuration for this pydantic object."""
|
||||
|
||||
arbitrary_types_allowed = True
|
||||
|
||||
def to_dict(self):
|
||||
return {k: self._serialize(v) for k, v in self.__dict__.items()}
|
||||
|
||||
@@ -146,7 +140,9 @@ class GptsAppResponse(BaseModel):
|
||||
total_count: Optional[int] = 0
|
||||
total_page: Optional[int] = 0
|
||||
current_page: Optional[int] = 0
|
||||
app_list: Optional[List[GptsApp]] = []
|
||||
app_list: Optional[List[GptsApp]] = Field(
|
||||
default_factory=list, description="app list"
|
||||
)
|
||||
|
||||
|
||||
class GptsAppCollection(BaseModel):
|
||||
@@ -207,7 +203,8 @@ class GptsAppEntity(Model):
|
||||
team_context = Column(
|
||||
Text,
|
||||
nullable=True,
|
||||
comment="The execution logic and team member content that teams with different working modes rely on",
|
||||
comment="The execution logic and team member content that teams with different "
|
||||
"working modes rely on",
|
||||
)
|
||||
|
||||
user_code = Column(String(255), nullable=True, comment="user code")
|
||||
@@ -565,7 +562,7 @@ def _parse_team_context(team_context: Optional[Union[str, AWELTeamContext]] = No
|
||||
parse team_context to str
|
||||
"""
|
||||
if isinstance(team_context, AWELTeamContext):
|
||||
return team_context.json()
|
||||
return model_to_json(team_context)
|
||||
return team_context
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user