@@ -102,6 +102,7 @@ def __init__(
102102 max_retries : int = 10 ,
103103 api_key : str | None = None ,
104104 api_base : str | None = None ,
105+ any_llm_args : dict [str , Any ] | None = None ,
105106 ** kwargs : Any ,
106107 ) -> None :
107108 additional_kwargs = additional_kwargs or {}
@@ -116,10 +117,14 @@ def __init__(
116117 )
117118
118119 self ._parse_model (model )
120+ llm_create_kwargs : dict [str , Any ] = dict (any_llm_args or {})
121+ if api_key is not None :
122+ llm_create_kwargs ["api_key" ] = api_key
123+ if api_base is not None :
124+ llm_create_kwargs ["api_base" ] = api_base
119125 self ._client = AnyLLM .create (
120126 provider = self ._provider ,
121- api_key = api_key ,
122- api_base = api_base ,
127+ ** llm_create_kwargs ,
123128 )
124129
125130 def _parse_model (self , model : str ) -> None :
@@ -512,14 +517,18 @@ def _get_model(self, agent_config: AgentConfig) -> "LLM":
512517
513518 model_id = agent_config .model_id
514519
520+ model_kwargs : dict [str , Any ] = {
521+ "model" : model_id ,
522+ "api_key" : agent_config .api_key ,
523+ "api_base" : agent_config .api_base ,
524+ "additional_kwargs" : additional_kwargs ,
525+ }
526+ if model_type is DEFAULT_MODEL_TYPE and agent_config .any_llm_args is not None :
527+ model_kwargs ["any_llm_args" ] = agent_config .any_llm_args
528+
515529 return cast (
516530 "LLM" ,
517- model_type (
518- model = model_id ,
519- api_key = agent_config .api_key ,
520- api_base = agent_config .api_base ,
521- additional_kwargs = additional_kwargs , # type: ignore[arg-type]
522- ),
531+ model_type (** model_kwargs ),
523532 )
524533
525534 async def _load_agent (self ) -> None :
0 commit comments