Skip to content

Commit

Permalink
Added conversational messages
Browse files Browse the repository at this point in the history
  • Loading branch information
penguine-ip committed Aug 7, 2024
1 parent 7545ee1 commit 102b33c
Show file tree
Hide file tree
Showing 13 changed files with 438 additions and 216 deletions.
19 changes: 19 additions & 0 deletions b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from deepeval.test_case import ConversationalTestCase, LLMTestCase, Message

from deepeval.metrics import AnswerRelevancyMetric, BiasMetric
from deepeval import evaluate


tc1 = LLMTestCase(input="hi again", actual_output="bye")
tc2 = LLMTestCase(input="hi", actual_output="bye")

c_test_case = ConversationalTestCase(
messages=[Message(llm_test_case=tc2), Message(llm_test_case=tc1)]
)


evaluate(
test_cases=[c_test_case, tc1],
metrics=[AnswerRelevancyMetric(), BiasMetric()],
run_async=False,
)
2 changes: 1 addition & 1 deletion deepeval/benchmarks/big_bench_hard/big_bench_hard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from deepeval.benchmarks.big_bench_hard.template import BigBenchHardTemplate
from deepeval.benchmarks.utils import should_use_batch
from deepeval.scorer import Scorer
from deepeval.benchmarks.models import *
from deepeval.benchmarks.schema import *


class BigBenchHard(DeepEvalBaseBenchmark):
Expand Down
25 changes: 24 additions & 1 deletion deepeval/dataset/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional
from deepeval.dataset.api import Golden, ConversationalGolden
from deepeval.test_case import LLMTestCase, ConversationalTestCase
from deepeval.test_case import LLMTestCase, ConversationalTestCase, Message


def convert_test_cases_to_goldens(
Expand Down Expand Up @@ -42,6 +42,29 @@ def convert_goldens_to_test_cases(
return test_cases


def convert_goldens_to_messages(
goldens: List[Golden],
_alias: Optional[str] = None,
_id: Optional[str] = None,
) -> List[Message]:
messages = []
for index, golden in enumerate(goldens):
test_case = LLMTestCase(
input=golden.input,
actual_output=golden.actual_output,
expected_output=golden.expected_output,
context=golden.context,
retrieval_context=golden.retrieval_context,
additional_metadata=golden.additional_metadata,
comments=golden.comments,
_dataset_alias=_alias,
_dataset_id=_id,
_dataset_rank=index,
)
messages.append(Message(test_case=test_case))
return messages


def convert_convo_goldens_to_convo_test_cases(
convo_goldens: List[ConversationalGolden],
_alias: Optional[str] = None,
Expand Down
Loading

0 comments on commit 102b33c

Please sign in to comment.