-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update mock components in eval harness test to correctly seriali…
…ze their params (#128)
- Loading branch information
Showing
1 changed file
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2022-present deepset GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from typing import Any, Dict, List, Optional | ||
from typing import Any, Dict, List, Optional, Union | ||
import pytest | ||
|
||
from haystack_experimental.evaluation.harness.rag import ( | ||
|
@@ -106,7 +106,9 @@ def run(self, query: str) -> Dict[str, Any]: | |
|
||
@component | ||
class MockEvaluator: | ||
def __init__(self, metric: RAGEvaluationMetric) -> None: | ||
def __init__(self, metric: Union[str, RAGEvaluationMetric]) -> None: | ||
if isinstance(metric, str): | ||
metric = RAGEvaluationMetric(metric) | ||
self.metric = metric | ||
|
||
io_map = { | ||
|
@@ -132,6 +134,9 @@ def __init__(self, metric: RAGEvaluationMetric) -> None: | |
self.__haystack_input__ = io_map[metric].__haystack_input__ | ||
self.__haystack_output__ = io_map[metric].__haystack_output__ | ||
|
||
def to_dict(self): | ||
return default_to_dict(self, metric=str(self.metric)) | ||
|
||
@staticmethod | ||
def default_output(metric) -> Dict[str, Any]: | ||
if metric in ( | ||
|