Skip to content

enable return_score for llmjudge #1698

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions pydantic_evals/pydantic_evals/evaluators/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from ..otel.span_tree import SpanQuery
from .context import EvaluatorContext
from .evaluator import EvaluationReason, Evaluator, EvaluatorOutput
from .evaluator import EvaluationReason, EvaluationScalar, Evaluator, EvaluatorOutput

__all__ = (
'Equals',
Expand Down Expand Up @@ -164,6 +164,7 @@ class LLMJudge(Evaluator[object, object, object]):
rubric: str
model: models.Model | models.KnownModelName | None = None
include_input: bool = False
return_score: bool = False

async def evaluate(
self,
Expand All @@ -177,7 +178,8 @@ async def evaluate(
from .llm_as_a_judge import judge_output

grading_output = await judge_output(ctx.output, self.rubric, self.model)
return EvaluationReason(value=grading_output.pass_, reason=grading_output.reason)
evaluation_value: EvaluationScalar = grading_output.score if self.return_score else grading_output.pass_
return EvaluationReason(value=evaluation_value, reason=grading_output.reason)

def build_serialization_arguments(self):
result = super().build_serialization_arguments()
Expand Down