@@ -69,13 +69,18 @@ class Compatible(BaseModel):
6969 allow_system_in_messages : bool = Field (default = True , description = "allow system messages in history" )
7070
7171
72+ class Azure (BaseModel ):
73+ api_key : str = Field (default = "" , description = "azure api key. if start with `$`, will read environment variable of it" )
74+ api_version : str = Field (default = "" , description = "azure api version" )
75+
76+
7277class ServiceConf (BaseModel ):
7378 """
7479 The model api service configuration
7580 """
7681
7782 name : str = Field (description = "Service name" )
78- base_url : str = Field (description = "LLM service url" )
83+ base_url : str = Field (description = "LLM service url. if start with `$`, will read environment variable of it " )
7984 token : str = Field (default = "" , description = "access token. if start with `$`, will read environment variable of it" )
8085 proxy : Optional [str ] = Field (
8186 default = None ,
@@ -92,10 +97,17 @@ class ServiceConf(BaseModel):
9297 description = "the model api compatible configuration" ,
9398 )
9499
100+ azure : Azure = Field (
101+ default_factory = Azure ,
102+ description = "azure service configuration" ,
103+ )
104+
95105 def load (self , environ : Optional [Dict ] = None ) -> None :
96- self .token = self ._load_env (self .token , environ = environ )
97- if self .proxy is not None :
98- self .proxy = self ._load_env (self .proxy , environ = environ )
106+ attributes = [(self , 'base_url' ), (self , 'token' ), (self , 'proxy' ), (self .azure , 'api_key' )]
107+ for obj , attr in attributes :
108+ value = getattr (obj , attr )
109+ if value is not None :
110+ setattr (obj , attr , self ._load_env (value , environ = environ ))
99111
100112 @staticmethod
101113 def _load_env (value : str , environ : Optional [Dict ] = None ) -> str :
0 commit comments