Skip to content
Merged
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
3 changes: 3 additions & 0 deletions agentplatform/_genai/_evals_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ def _extract_dataset_rows(dataset: types.EvaluationDataset) -> list[dict[str, An
return processed_rows


extract_dataset_rows = _extract_dataset_rows


def get_evaluation_html(eval_result_json: str) -> str:
"""Returns a self-contained HTML for single evaluation visualization."""
payload_b64 = _encode_to_base64(eval_result_json)
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/agentplatform/genai/test_evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,36 @@ def test_get_inference_html(self):
assert payload_b64 in html
assert "DOMPurify" in html

def test_extract_dataset_rows(self):
dataset = common_types.EvaluationDataset(
eval_cases=[
common_types.EvalCase(
prompt=genai_types.Content(
parts=[genai_types.Part(text="What is 2+2?")]
),
responses=[
common_types.ResponseCandidate(
response=genai_types.Content(
parts=[genai_types.Part(text="4")]
)
)
],
reference=common_types.ResponseCandidate(
response=genai_types.Content(
parts=[genai_types.Part(text="Four")]
)
),
)
]
)

rows = _evals_visualization.extract_dataset_rows(dataset)

assert len(rows) == 1
assert rows[0]["prompt_display_text"] == "What is 2+2?"
assert rows[0]["response_display_text"] == "4"
assert rows[0]["reference"] == "Four"

def test_display_loss_clusters_response_no_ipython(self):
"""Tests graceful fallback when not in IPython."""
from agentplatform._genai import _evals_visualization
Expand Down
Loading