Skip to content
Open
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 agentplatform/_genai/types/evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ class RubricVerdict(_common.BaseModel):
generated.""",
)
verdict: Optional[bool] = Field(
default=None,
default=False,
description="""Required. Outcome of the evaluation against the rubric, represented as a
boolean. `true` indicates a "Pass", `false` indicates a "Fail".""",
)
Expand Down
44 changes: 44 additions & 0 deletions tests/unit/agentplatform/genai/test_evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
types as agentplatform_genai_types,
)
from agentplatform._genai.types import common as common_types
from vertexai._genai import evals as vertexai_evals
from google.genai import client
from google.genai import errors as genai_errors
from google.genai import types as genai_types
Expand Down Expand Up @@ -2311,6 +2312,49 @@ def test_eval_evaluate_with_agent_info(self, mock_execute_evaluation):
assert kwargs["agent_info"] == agent_info


class TestRubricVerdict:
"""Unit tests for parsing RubricVerdict from API responses."""

@pytest.mark.parametrize(
"evals_module", [evals, vertexai_evals], ids=["agent_platform", "vertexai"]
)
def test_evaluate_instances_missing_verdict_is_false(self, evals_module):
api_client = mock.MagicMock()
api_client.vertexai = True
api_client.request.return_value.body = json.dumps(
{
"metricResults": [
{
"score": 0.5,
"rubricVerdicts": [
{
"evaluatedRubric": {
"content": {
"property": {"description": "In English."}
}
},
"verdict": True,
},
{
"evaluatedRubric": {
"content": {
"property": {"description": "One sentence."}
}
},
"reasoning": "The response has two sentences.",
},
],
}
]
}
)

response = evals_module.Evals(api_client_=api_client)._evaluate_instances()

verdicts = response.metric_results[0].rubric_verdicts
assert [verdict.verdict for verdict in verdicts] == [True, False]


class TestEvalsVisualization:
# fmt: off
@mock.patch(
Expand Down
2 changes: 1 addition & 1 deletion vertexai/_genai/types/evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ class RubricVerdict(_common.BaseModel):
generated.""",
)
verdict: Optional[bool] = Field(
default=None,
default=False,
description="""Required. Outcome of the evaluation against the rubric, represented as a
boolean. `true` indicates a "Pass", `false` indicates a "Fail".""",
)
Expand Down
Loading