@@ -170,30 +170,37 @@ def validate_execution_time(cls, v: float) -> float:
170170
171171
172172class LLMConfig (BaseModel ):
173- """LLM Configuration with validation ."""
173+ """LLM configuration from system configuration ."""
174174
175- model_name : str = Field (..., description = "The model name to use" )
176- api_base : Optional [str ] = Field (None , description = "Custom API base URL" )
177- api_key : Optional [str ] = Field (None , description = "API key for the model" )
178- temperature : float = Field (
179- 0.0 , ge = 0.0 , le = 2.0 , description = "Temperature for sampling"
180- )
181- max_tokens : Optional [int ] = Field (
182- None , ge = 1 , description = "Maximum tokens to generate"
183- )
184- timeout : Optional [int ] = Field (None , ge = 1 , description = "Request timeout in seconds" )
185- num_retries : int = Field (
186- 3 , ge = 0 , description = "Number of retries for failed requests"
175+ provider : str = Field (
176+ ..., description = "Provider name, e.g., openai, azure, watsonx"
187177 )
178+ model : str = Field (..., description = "Model identifier or deployment name" )
179+ temperature : float = Field (0.0 , ge = 0.0 , le = 2.0 , description = "Sampling temperature" )
180+ max_tokens : int = Field (512 , ge = 1 , description = "Maximum tokens in response" )
181+ timeout : int = Field (300 , ge = 1 , description = "Request timeout in seconds" )
182+ num_retries : int = Field (3 , ge = 0 , description = "Retry attempts for failed requests" )
188183
189- @field_validator ("model_name " )
184+ @field_validator ("provider" , "model " )
190185 @classmethod
191- def validate_model_name (cls , v : str ) -> str :
192- """Validate model name is non-empty."""
193- if not v or not v .strip ():
194- raise ValueError ("Model name cannot be empty" )
186+ def _validate_non_empty (cls , v : str ) -> str :
187+ """Validate provider and model are non-empty strings ."""
188+ if not v or not isinstance ( v , str ) or not v .strip ():
189+ raise ValueError ("Value cannot be empty" )
195190 return v .strip ()
196191
192+ @classmethod
193+ def from_dict (cls , config_dict : Dict [str , Any ]) -> "LLMConfig" :
194+ """Create LLMConfig from a plain dictionary."""
195+ return cls (
196+ provider = config_dict .get ("provider" , "openai" ),
197+ model = config_dict .get ("model" , "gpt-4o-mini" ),
198+ temperature = config_dict .get ("temperature" , 0.0 ),
199+ max_tokens = config_dict .get ("max_tokens" , 512 ),
200+ timeout = config_dict .get ("timeout" , 300 ),
201+ num_retries = config_dict .get ("num_retries" , 3 ),
202+ )
203+
197204
198205# System configuration models
199206class EvaluationSystemConfig (BaseModel ):
0 commit comments