Skip to content

Commit

Permalink
Merge branch 'main' into llmmetadata-extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsbatista authored Oct 30, 2024
2 parents a9b8bca + 4e1b37a commit b655014
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/evaluation/harness/rag/test_harness.py
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 (
Expand Down Expand Up @@ -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 = {
Expand All @@ -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 (
Expand Down

0 comments on commit b655014

Please sign in to comment.