@@ -32,6 +32,7 @@ class OpenAIOptions(BaseModel):
3232 template_variables : Optional [Dict [str , str ]] = Field (default = None )
3333 vendor : Optional [str ] = Field (default = None )
3434 mcp_servers : Optional [List [Dict [str , Any ]]] = Field (default = None )
35+ max_history : Optional [int ] = Field (default = None , gt = 0 , description = "Maximum number of conversation history messages to cache" )
3536
3637 class Config :
3738 extra = "forbid"
@@ -78,6 +79,8 @@ def to_config(self) -> Dict[str, Any]:
7879 config ["vendor" ] = self .options .vendor
7980 if self .options .mcp_servers is not None :
8081 config ["mcp_servers" ] = _ensure_mcp_transport (self .options .mcp_servers )
82+ if self .options .max_history is not None :
83+ config ["max_history" ] = self .options .max_history
8184
8285 return config
8386
@@ -94,11 +97,13 @@ class AzureOpenAIOptions(BaseModel):
9497 greeting_message : Optional [str ] = Field (default = None )
9598 failure_message : Optional [str ] = Field (default = None )
9699 input_modalities : Optional [List [str ]] = Field (default = None )
100+ params : Optional [Dict [str , Any ]] = Field (default = None )
97101 output_modalities : Optional [List [str ]] = Field (default = None )
98102 greeting_configs : Optional [Dict [str , Any ]] = Field (default = None )
99103 template_variables : Optional [Dict [str , str ]] = Field (default = None )
100104 vendor : Optional [str ] = Field (default = None )
101105 mcp_servers : Optional [List [Dict [str , Any ]]] = Field (default = None )
106+ max_history : Optional [int ] = Field (default = None , gt = 0 , description = "Maximum number of conversation history messages to cache" )
102107
103108 class Config :
104109 extra = "forbid"
@@ -122,7 +127,8 @@ def to_config(self) -> Dict[str, Any]:
122127 "input_modalities" : self .options .input_modalities or ["text" ],
123128 }
124129
125- params : Dict [str , Any ] = {}
130+ # Named fields take precedence over anything in the generic params dict.
131+ params : Dict [str , Any ] = dict (self .options .params or {})
126132 if self .options .temperature is not None :
127133 params ["temperature" ] = self .options .temperature
128134 if self .options .top_p is not None :
@@ -146,25 +152,30 @@ def to_config(self) -> Dict[str, Any]:
146152 config ["template_variables" ] = self .options .template_variables
147153 if self .options .mcp_servers is not None :
148154 config ["mcp_servers" ] = _ensure_mcp_transport (self .options .mcp_servers )
155+ if self .options .max_history is not None :
156+ config ["max_history" ] = self .options .max_history
149157
150158 return config
151159
152160
153161class AnthropicOptions (BaseModel ):
154162 api_key : str = Field (..., description = "Anthropic API key" )
155163 model : str = Field (default = "claude-3-5-sonnet-20241022" , description = "Model name" )
164+ url : Optional [str ] = Field (default = None , description = "Custom API endpoint URL" )
156165 max_tokens : Optional [int ] = Field (default = None , gt = 0 )
157166 temperature : Optional [float ] = Field (default = None , ge = 0.0 , le = 1.0 )
158167 top_p : Optional [float ] = Field (default = None , ge = 0.0 , le = 1.0 )
159168 system_messages : Optional [List [Dict [str , Any ]]] = Field (default = None )
160169 greeting_message : Optional [str ] = Field (default = None )
161170 failure_message : Optional [str ] = Field (default = None )
162171 input_modalities : Optional [List [str ]] = Field (default = None )
172+ params : Optional [Dict [str , Any ]] = Field (default = None )
163173 output_modalities : Optional [List [str ]] = Field (default = None )
164174 greeting_configs : Optional [Dict [str , Any ]] = Field (default = None )
165175 template_variables : Optional [Dict [str , str ]] = Field (default = None )
166176 vendor : Optional [str ] = Field (default = None )
167177 mcp_servers : Optional [List [Dict [str , Any ]]] = Field (default = None )
178+ max_history : Optional [int ] = Field (default = None , gt = 0 , description = "Maximum number of conversation history messages to cache" )
168179
169180 class Config :
170181 extra = "forbid"
@@ -175,20 +186,23 @@ def __init__(self, **kwargs: Any):
175186 self .options = AnthropicOptions (** kwargs )
176187
177188 def to_config (self ) -> Dict [str , Any ]:
189+ # Named fields take precedence over anything in the generic params dict.
190+ params : Dict [str , Any ] = {"model" : self .options .model , ** (self .options .params or {})}
191+ if self .options .max_tokens is not None :
192+ params ["max_tokens" ] = self .options .max_tokens
193+ if self .options .temperature is not None :
194+ params ["temperature" ] = self .options .temperature
195+ if self .options .top_p is not None :
196+ params ["top_p" ] = self .options .top_p
197+
178198 config : Dict [str , Any ] = {
179- "url" : "https://api.anthropic.com/v1/messages" ,
199+ "url" : self . options . url or "https://api.anthropic.com/v1/messages" ,
180200 "api_key" : self .options .api_key ,
181- "params" : { "model" : self . options . model } ,
201+ "params" : params ,
182202 "style" : "anthropic" ,
183203 "input_modalities" : self .options .input_modalities or ["text" ],
184204 }
185205
186- if self .options .max_tokens is not None :
187- config ["params" ]["max_tokens" ] = self .options .max_tokens
188- if self .options .temperature is not None :
189- config ["params" ]["temperature" ] = self .options .temperature
190- if self .options .top_p is not None :
191- config ["params" ]["top_p" ] = self .options .top_p
192206 if self .options .system_messages is not None :
193207 config ["system_messages" ] = self .options .system_messages
194208 if self .options .greeting_message is not None :
@@ -205,13 +219,16 @@ def to_config(self) -> Dict[str, Any]:
205219 config ["vendor" ] = self .options .vendor
206220 if self .options .mcp_servers is not None :
207221 config ["mcp_servers" ] = _ensure_mcp_transport (self .options .mcp_servers )
222+ if self .options .max_history is not None :
223+ config ["max_history" ] = self .options .max_history
208224
209225 return config
210226
211227
212228class GeminiOptions (BaseModel ):
213229 api_key : str = Field (..., description = "Google AI API key" )
214230 model : str = Field (default = "gemini-2.0-flash-exp" , description = "Model name" )
231+ url : Optional [str ] = Field (default = None , description = "Custom API endpoint URL" )
215232 temperature : Optional [float ] = Field (default = None , ge = 0.0 , le = 2.0 )
216233 top_p : Optional [float ] = Field (default = None , ge = 0.0 , le = 1.0 )
217234 top_k : Optional [int ] = Field (default = None , gt = 0 )
@@ -220,11 +237,13 @@ class GeminiOptions(BaseModel):
220237 greeting_message : Optional [str ] = Field (default = None )
221238 failure_message : Optional [str ] = Field (default = None )
222239 input_modalities : Optional [List [str ]] = Field (default = None )
240+ params : Optional [Dict [str , Any ]] = Field (default = None )
223241 output_modalities : Optional [List [str ]] = Field (default = None )
224242 greeting_configs : Optional [Dict [str , Any ]] = Field (default = None )
225243 template_variables : Optional [Dict [str , str ]] = Field (default = None )
226244 vendor : Optional [str ] = Field (default = None )
227245 mcp_servers : Optional [List [Dict [str , Any ]]] = Field (default = None )
246+ max_history : Optional [int ] = Field (default = None , gt = 0 , description = "Maximum number of conversation history messages to cache" )
228247
229248 class Config :
230249 extra = "forbid"
@@ -235,22 +254,25 @@ def __init__(self, **kwargs: Any):
235254 self .options = GeminiOptions (** kwargs )
236255
237256 def to_config (self ) -> Dict [str , Any ]:
257+ # Named fields take precedence over anything in the generic params dict.
258+ params : Dict [str , Any ] = {"model" : self .options .model , ** (self .options .params or {})}
259+ if self .options .temperature is not None :
260+ params ["temperature" ] = self .options .temperature
261+ if self .options .top_p is not None :
262+ params ["top_p" ] = self .options .top_p
263+ if self .options .top_k is not None :
264+ params ["top_k" ] = self .options .top_k
265+ if self .options .max_output_tokens is not None :
266+ params ["max_output_tokens" ] = self .options .max_output_tokens
267+
238268 config : Dict [str , Any ] = {
239- "url" : "https://generativelanguage.googleapis.com/v1beta/models" ,
269+ "url" : self . options . url or "https://generativelanguage.googleapis.com/v1beta/models" ,
240270 "api_key" : self .options .api_key ,
241- "params" : { "model" : self . options . model } ,
271+ "params" : params ,
242272 "style" : "gemini" ,
243273 "input_modalities" : self .options .input_modalities or ["text" ],
244274 }
245275
246- if self .options .temperature is not None :
247- config ["params" ]["temperature" ] = self .options .temperature
248- if self .options .top_p is not None :
249- config ["params" ]["top_p" ] = self .options .top_p
250- if self .options .top_k is not None :
251- config ["params" ]["top_k" ] = self .options .top_k
252- if self .options .max_output_tokens is not None :
253- config ["params" ]["max_output_tokens" ] = self .options .max_output_tokens
254276 if self .options .system_messages is not None :
255277 config ["system_messages" ] = self .options .system_messages
256278 if self .options .greeting_message is not None :
@@ -267,5 +289,7 @@ def to_config(self) -> Dict[str, Any]:
267289 config ["vendor" ] = self .options .vendor
268290 if self .options .mcp_servers is not None :
269291 config ["mcp_servers" ] = _ensure_mcp_transport (self .options .mcp_servers )
292+ if self .options .max_history is not None :
293+ config ["max_history" ] = self .options .max_history
270294
271295 return config
0 commit comments