1212 model_validator ,
1313)
1414
15- from lightspeed_evaluation .core .system .exceptions import ConfigurationError
1615from lightspeed_evaluation .core .constants import (
1716 DEFAULT_API_BASE ,
1817 DEFAULT_API_CACHE_DIR ,
4544 SUPPORTED_GRAPH_TYPES ,
4645 SUPPORTED_OUTPUT_TYPES ,
4746)
47+ from lightspeed_evaluation .core .system .exceptions import ConfigurationError
4848
4949
5050class LLMConfig (BaseModel ):
@@ -82,7 +82,7 @@ def validate_ssl_cert_file(self) -> "LLMConfig":
8282
8383 # Check if file exists
8484 if not os .path .isfile (cert_path ):
85- raise ValueError (
85+ raise ConfigurationError (
8686 f"SSL certificate file not found: '{ cert_path } '. "
8787 f"Original path: '{ self .ssl_cert_file } '. "
8888 "Please provide a valid path to a CA certificate file "
@@ -519,10 +519,10 @@ def resolve_llm_config(
519519 Fully resolved LLMConfig
520520
521521 Raises:
522- ValueError : If model_id not found
522+ ConfigurationError : If model_id not found
523523 """
524524 if model_id not in self .models :
525- raise ValueError (
525+ raise ConfigurationError (
526526 f"Model '{ model_id } ' not found in llm_pool.models. "
527527 f"Available: { list (self .models .keys ())} "
528528 )
@@ -687,7 +687,7 @@ def validate_rubrics_non_overlapping(self) -> "GEvalConfig":
687687 continue
688688 # Overlap if not (b < c or d < a)
689689 if not (b < c or d < a ):
690- raise ValueError (
690+ raise ConfigurationError (
691691 f"Rubric score ranges must not overlap: "
692692 f"[{ a } , { b } ] and [{ c } , { d } ] overlap"
693693 )
@@ -708,9 +708,9 @@ def from_metadata(cls, raw: dict[str, Any]) -> "GEvalConfig":
708708 ValueError: If raw is not a dict or criteria is missing/empty
709709 (only these pre-model_validate checks raise bare ValueError).
710710 ValidationError: If rubric or config fields fail Pydantic validation:
711- wrong types (e.g. score_range, expected_outcome), invalid structure,
712- or overlapping score ranges (model validator raises ValueError
713- and Pydantic v2 wraps it as ValidationError ).
711+ wrong types (e.g. score_range, expected_outcome), invalid structure.
712+ ConfigurationError: If rubric score ranges overlap (model validator
713+ raises ConfigurationError directly, bypassing Pydantic wrapping ).
714714 """
715715 if not isinstance (raw , dict ):
716716 raise ValueError ("GEval config must be a dict" )
@@ -801,17 +801,17 @@ def validate_default_metrics_metadata_geval(
801801
802802 Raises:
803803 ConfigurationError: When a geval:* entry has invalid config (e.g.
804- missing criteria, invalid rubric structure).
805- Re-raised from ValueError or Pydantic ValidationError for a consistent
806- config-failure exception type.
804+ missing criteria, invalid rubric structure, overlapping rubrics ).
805+ Re-raised from ValueError, ValidationError, or ConfigurationError
806+ for a consistent config-failure exception type with metric context .
807807 """
808808 if not v :
809809 return v
810810 for metric_id , meta in v .items ():
811811 if metric_id .startswith ("geval:" ) and isinstance (meta , dict ):
812812 try :
813813 GEvalConfig .from_metadata (meta )
814- except (ValueError , ValidationError ) as e :
814+ except (ValueError , ValidationError , ConfigurationError ) as e :
815815 raise ConfigurationError (
816816 f"Invalid GEval config for '{ metric_id } ': { e !s} "
817817 ) from e
0 commit comments