From dca5127c2de03dabefda3c9ecba8713a1ce2b310 Mon Sep 17 00:00:00 2001 From: Julian Risch Date: Thu, 15 Feb 2024 21:06:16 +0100 Subject: [PATCH] always call the default metric_params_validator --- .../components/evaluators/ragas/evaluator.py | 5 ++++- .../components/evaluators/ragas/metrics.py | 11 +---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/integrations/ragas/src/haystack_integrations/components/evaluators/ragas/evaluator.py b/integrations/ragas/src/haystack_integrations/components/evaluators/ragas/evaluator.py index 50b4d0661..7e088b47d 100644 --- a/integrations/ragas/src/haystack_integrations/components/evaluators/ragas/evaluator.py +++ b/integrations/ragas/src/haystack_integrations/components/evaluators/ragas/evaluator.py @@ -11,6 +11,7 @@ from .metrics import ( METRIC_DESCRIPTORS, InputConverters, + MetricParamsValidator, OutputConverters, RagasMetric, ) @@ -61,7 +62,9 @@ def _init_backend(self): self._backend_callable = RagasEvaluator._invoke_evaluate def _init_metric(self): - self.descriptor.metric_params_validator(self.metric, self.descriptor.init_parameters, self.metric_params) + MetricParamsValidator.validate_metric_parameters( + self.metric, self.descriptor.init_parameters, self.metric_params + ) self._backend_metric = self.descriptor.backend(**self.metric_params) @staticmethod diff --git a/integrations/ragas/src/haystack_integrations/components/evaluators/ragas/metrics.py b/integrations/ragas/src/haystack_integrations/components/evaluators/ragas/metrics.py index f721d31ee..8d1f53593 100644 --- a/integrations/ragas/src/haystack_integrations/components/evaluators/ragas/metrics.py +++ b/integrations/ragas/src/haystack_integrations/components/evaluators/ragas/metrics.py @@ -114,8 +114,6 @@ class MetricDescriptor: The metric. :param backend: The associated Ragas metric class. - :param metric_params_validator: - Callable that validates metric parameters. :param input_parameters: Parameters accepted by the metric. This is used to set the input types of the evaluator component. @@ -133,7 +131,6 @@ class MetricDescriptor: input_parameters: Dict[str, Type] input_converter: Callable[[Any], Iterable[Dict[str, str]]] output_converter: Callable[[Result, RagasMetric, Dict[str, Any]], List[MetricResult]] - metric_params_validator: Callable[[RagasMetric, List[str], Dict[str, Any]], None] init_parameters: Optional[List[str]] = None @classmethod @@ -143,7 +140,6 @@ def new( backend: Type[Metric], input_converter: Callable[[Any], Iterable[Dict[str, str]]], output_converter: Optional[Callable[[Result, RagasMetric, Dict[str, Any]], List[MetricResult]]] = None, - metric_params_validator: Optional[Callable[[RagasMetric, List[str], Dict[str, Any]], None]] = None, *, init_parameters: Optional[List[str]] = None, ) -> "MetricDescriptor": @@ -162,16 +158,11 @@ def new( input_parameters=input_parameters, input_converter=input_converter, output_converter=output_converter if output_converter is not None else OutputConverters.default, - metric_params_validator=( - metric_params_validator - if metric_params_validator is not None - else MetricParamsValidators.validate_metric_parameters - ), init_parameters=init_parameters, ) -class MetricParamsValidators: +class MetricParamsValidator: """ Validates metric parameters.