Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix error #44

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deepeval/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__: str = "0.9.4"
__version__: str = "0.9.5"
3 changes: 3 additions & 0 deletions deepeval/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def run_evaluation(
max_retries: int = 3,
min_success: int = 1,
raise_error: bool = False,
metrics: List[TestCase] = None,
):
table = []

Expand Down Expand Up @@ -211,6 +212,8 @@ def assert_metric():
else:
try:
assert_metric()
except AssertionError as e:
print(e)
except Exception as e:
print(e)
if test_filename is None:
Expand Down
10 changes: 10 additions & 0 deletions deepeval/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


class Metric:
_success: bool = False

@abstractmethod
def measure(self, output, expected_output, query: Optional[str] = None):
pass
Expand All @@ -31,6 +33,14 @@ def _get_init_values(self):
}
return init_values

@property
def success(self):
return self._success

@success.setter
def success(self, value):
self._success = value

@abstractmethod
def is_successful(self) -> bool:
return False
Expand Down
4 changes: 2 additions & 2 deletions deepeval/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import UserList
from .metrics.metric import Metric
from .metrics.randomscore import RandomMetric
from .metrics.entailment_metric import EntailmentScoreMetric
from .metrics.factual_consistency import FactualConsistencyMetric


class TestCase:
Expand All @@ -15,7 +15,7 @@ def __init__(
id: str = None,
):
if metrics is None:
self.metrics = [EntailmentScoreMetric(minimum_score=0.3)]
self.metrics = [FactualConsistencyMetric(minimum_score=0.3)]
else:
self.metrics = metrics
self.input = input
Expand Down