1-
21from typing import Optional
2+
3+ from pydantic import field_serializer
34from sqlmodel import BigInteger , Field , Text , SQLModel
5+
46from common .core .models import SnowflakeBase
57from common .core .schemas import BaseCreatorDTO
68
@@ -9,84 +11,98 @@ class AiModelBase:
911 supplier : int = Field (nullable = False )
1012 name : str = Field (max_length = 255 , nullable = False )
1113 model_type : int = Field (nullable = False )
12- base_model : str = Field (max_length = 255 , nullable = False )
14+ base_model : str = Field (max_length = 255 , nullable = False )
1315 default_model : bool = Field (default = False , nullable = False )
1416
17+
1518class AiModelDetail (SnowflakeBase , AiModelBase , table = True ):
16- __tablename__ = "ai_model"
17- api_key : str | None = Field (default = None , nullable = True , sa_type = Text ())
18- api_domain : str = Field (nullable = False , sa_type = Text ())
19- protocol : int = Field (nullable = False , default = 1 )
20- config : str = Field (sa_type = Text ())
21- status : int = Field (nullable = False , default = 1 )
22- create_time : int = Field (default = 0 , sa_type = BigInteger ())
23-
19+ __tablename__ = "ai_model"
20+ api_key : str | None = Field (default = None , nullable = True , sa_type = Text ())
21+ api_domain : str = Field (nullable = False , sa_type = Text ())
22+ protocol : int = Field (nullable = False , default = 1 )
23+ config : str = Field (sa_type = Text ())
24+ status : int = Field (nullable = False , default = 1 )
25+ create_time : int = Field (default = 0 , sa_type = BigInteger ())
26+
27+
2428class AiModelWorkspaceMapping (SnowflakeBase , table = True ):
2529 __tablename__ = "ai_model_workspace_mapping"
2630 ai_model_id : int = Field (default = None , nullable = True , sa_type = BigInteger ())
2731 workspace_id : int = Field (default = None , nullable = True , sa_type = BigInteger ())
2832
33+
2934class AiModelBrief (SQLModel ):
3035 id : int
3136 name : str
3237 default_model : bool
3338 supplier : int
3439
40+ @field_serializer ("id" )
41+ def id_to_str (self , v : int ) -> str :
42+ return str (v )
43+
44+
3545class WorkspaceBase (SQLModel ):
3646 name : str = Field (max_length = 255 , nullable = False )
3747
48+
3849class WorkspaceEditor (WorkspaceBase , BaseCreatorDTO ):
3950 pass
40-
51+
52+
4153class WorkspaceModel (SnowflakeBase , WorkspaceBase , table = True ):
4254 __tablename__ = "sys_workspace"
4355 create_time : int = Field (default = 0 , sa_type = BigInteger ())
44-
56+
57+
4558class UserWsBaseModel (SQLModel ):
4659 uid : int = Field (nullable = False , sa_type = BigInteger ())
4760 oid : int = Field (nullable = False , sa_type = BigInteger ())
48- weight : int = Field (default = 0 , nullable = False )
49-
61+ weight : int = Field (default = 0 , nullable = False )
62+
63+
5064class UserWsModel (SnowflakeBase , UserWsBaseModel , table = True ):
5165 __tablename__ = "sys_user_ws"
52-
66+
5367
5468class AssistantBaseModel (SQLModel ):
5569 name : str = Field (max_length = 255 , nullable = False )
5670 type : int = Field (nullable = False , default = 0 )
5771 domain : str = Field (max_length = 255 , nullable = False )
58- description : Optional [str ] = Field (sa_type = Text (), nullable = True )
59- configuration : Optional [str ] = Field (sa_type = Text (), nullable = True )
72+ description : Optional [str ] = Field (sa_type = Text (), nullable = True )
73+ configuration : Optional [str ] = Field (sa_type = Text (), nullable = True )
6074 create_time : int = Field (default = 0 , sa_type = BigInteger ())
61- app_id : Optional [str ] = Field (default = None , max_length = 255 , nullable = True )
75+ app_id : Optional [str ] = Field (default = None , max_length = 255 , nullable = True )
6276 app_secret : Optional [str ] = Field (default = None , max_length = 255 , nullable = True )
6377 oid : Optional [int ] = Field (nullable = True , sa_type = BigInteger (), default = 1 )
6478 enable_custom_model : Optional [bool ] = Field (default = False , nullable = True )
6579 custom_model : Optional [str ] = Field (default = None , max_length = 255 , nullable = True )
6680
81+
6782class AssistantModel (SnowflakeBase , AssistantBaseModel , table = True ):
6883 __tablename__ = "sys_assistant"
69-
84+
7085
7186class AuthenticationBaseModel (SQLModel ):
7287 name : str = Field (max_length = 255 , nullable = False )
7388 type : int = Field (nullable = False , default = 0 )
74- config : Optional [str ] = Field (sa_type = Text (), nullable = True )
75-
76-
89+ config : Optional [str ] = Field (sa_type = Text (), nullable = True )
90+
91+
7792class AuthenticationModel (SnowflakeBase , AuthenticationBaseModel , table = True ):
7893 __tablename__ = "sys_authentication"
7994 create_time : Optional [int ] = Field (default = 0 , sa_type = BigInteger ())
8095 enable : bool = Field (default = False , nullable = False )
8196 valid : bool = Field (default = False , nullable = False )
82-
97+
8398
8499class ApiKeyBaseModel (SQLModel ):
85100 access_key : str = Field (max_length = 255 , nullable = False )
86101 secret_key : str = Field (max_length = 255 , nullable = False )
87102 create_time : int = Field (default = 0 , sa_type = BigInteger ())
88- uid : int = Field (default = 0 ,nullable = False , sa_type = BigInteger ())
103+ uid : int = Field (default = 0 , nullable = False , sa_type = BigInteger ())
89104 status : bool = Field (default = True , nullable = False )
90-
105+
106+
91107class ApiKeyModel (SnowflakeBase , ApiKeyBaseModel , table = True ):
92- __tablename__ = "sys_apikey"
108+ __tablename__ = "sys_apikey"
0 commit comments