Skip to content

Commit

Permalink
Merge pull request #1425 from kritinv/geval-update
Browse files Browse the repository at this point in the history
update g_eval.py
  • Loading branch information
penguine-ip authored Mar 10, 2025
2 parents 422e4f6 + 82e3fb5 commit f832a9a
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion deepeval/metrics/g_eval/g_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
check_llm_test_case_params,
initialize_model,
)
from deepeval.models import DeepEvalBaseLLM
from deepeval.models import DeepEvalBaseLLM, GPTModel
from deepeval.metrics.indicator import metric_progress_indicator
from deepeval.metrics.g_eval.schema import *

Expand Down Expand Up @@ -245,6 +245,20 @@ async def _a_evaluate(
)

try:
# don't use log probabilities for unsupported gpt models
unsupported_gpt_models = {
"o1",
"o1-preview",
"o1-2024-12-17",
"o3-mini",
"o3-mini-2025-01-31",
}
if isinstance(self.model, str) and self.model in unsupported_gpt_models:
raise AttributeError(f"Model {self.model} is unsupported.")
if isinstance(self.model, GPTModel) and self.model.model_name in unsupported_gpt_models:
raise AttributeError(f"Model {self.model.model} is unsupported.")


# Don't have to check for using native model
# since generate raw response only exist for deepeval's native model
res, cost = await self.model.a_generate_raw_response(
Expand Down Expand Up @@ -310,6 +324,19 @@ def evaluate(self, test_case: LLMTestCase) -> Tuple[Union[int, float], str]:
)

try:
# don't use log probabilities for unsupported gpt models
unsupported_gpt_models = {
"o1",
"o1-preview",
"o1-2024-12-17",
"o3-mini",
"o3-mini-2025-01-31",
}
if isinstance(self.model, str) and self.model in unsupported_gpt_models:
raise AttributeError(f"Model {self.model} is unsupported.")
if isinstance(self.model, GPTModel) and self.model.model in unsupported_gpt_models:
raise AttributeError(f"Model {self.model.model} is unsupported.")

res, cost = self.model.generate_raw_response(
prompt, logprobs=True, top_logprobs=self.top_logprobs
)
Expand Down

0 comments on commit f832a9a

Please sign in to comment.