forked from confident-ai/deepeval
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkk.py
More file actions
38 lines (29 loc) · 901 Bytes
/
kk.py
File metadata and controls
38 lines (29 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from deepeval import evaluate
from deepeval.metrics import ToolCorrectnessMetric, BaseMetric
from deepeval.test_case import LLMTestCase
testset = LLMTestCase(
input="What is the capital of France?",
expected_output="Paris",
)
class FakeMetric1(BaseMetric):
def __init__(self, threshold: float = 0.5, _success: bool = True):
self.threshold = threshold
self.success = _success
def measure(self, test_case: LLMTestCase):
self.reason = "This metric looking good!"
return self.score
async def a_measure(self, test_case: LLMTestCase):
self.score = 0.5
self.reason = "This async metric looking good!"
return self.score
def is_successful(self):
return self.success
@property
def __name__(self):
return "Fake"
evaluate(
test_cases=[testset] * 80,
metrics=[
FakeMetric1(),
],
)