GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: GenAI Client(evals) - Show intermediate_events as a conversation… · hamgor/python-aiplatform@4d4ac8a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • agentplatform/_genai
    • _evals_visualization.py
  • tests/unit/agentplatform/genai
    • test_evals.py
  • vertexai/_genai
    • _evals_visualization.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎agentplatform/_genai/_evals_visualization.py‎

Copy file name to clipboardExpand all lines: agentplatform/_genai/_evals_visualization.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ def _extract_dataset_rows(dataset: types.EvaluationDataset) -> list[dict[str, An
229229
}
230230
processed_rows.append(processed_row)
231231

232+
for row in processed_rows:
233+
if isinstance(row["agent_data"], str) or not isinstance(
234+
row["intermediate_events"], str
235+
):
236+
continue
237+
try:
238+
events = json.loads(row["intermediate_events"])
239+
except json.JSONDecodeError:
240+
continue
241+
if isinstance(events, list) and events:
242+
row["agent_data"] = json.dumps(
243+
{"turns": [{"turn_index": 0, "events": events}]}, ensure_ascii=False
244+
)
245+
232246
return processed_rows
233247

234248

Collapse file

‎tests/unit/agentplatform/genai/test_evals.py‎

Copy file name to clipboardExpand all lines: tests/unit/agentplatform/genai/test_evals.py
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,13 +2382,20 @@ def test_display_evaluation_result_with_agent_trace_prefixes(self, mock_is_ipyth
23822382
}
23832383
},
23842384
]
2385+
agent_data = {"turns": [{"turn_index": 3, "turn_id": "t3", "events": []}]}
23852386
dataset_df = pd.DataFrame(
23862387
[
23872388
{
23882389
"prompt": "Test prompt",
23892390
"response": "Test response",
23902391
"intermediate_events": intermediate_events_list,
23912392
},
2393+
{
2394+
"prompt": "Test prompt 2",
2395+
"response": "Test response 2",
2396+
"intermediate_events": intermediate_events_list,
2397+
"agent_data": agent_data,
2398+
},
23922399
]
23932400
)
23942401
eval_dataset = agentplatform_genai_types.EvaluationDataset(
@@ -2415,9 +2422,12 @@ def test_display_evaluation_result_with_agent_trace_prefixes(self, mock_is_ipyth
24152422
html_content = mock_display_module.HTML.call_args[0][0]
24162423
match = re.search(r'atob\("([^"]+)"\)', html_content)
24172424
assert match
2418-
decoded_json = base64.b64decode(match.group(1)).decode("utf-8")
2419-
assert "my_function" in decoded_json
2420-
assert "this is model response" in decoded_json
2425+
payload = json.loads(base64.b64decode(match.group(1)).decode("utf-8"))
2426+
rows = payload["metadata"]["dataset"]
2427+
assert json.loads(rows[0]["agent_data"]) == {
2428+
"turns": [{"turn_index": 0, "events": intermediate_events_list}]
2429+
}
2430+
assert json.loads(rows[1]["agent_data"]) == agent_data
24212431

24222432
del sys.modules["IPython"]
24232433
del sys.modules["IPython.display"]
Collapse file

‎vertexai/_genai/_evals_visualization.py‎

Copy file name to clipboardExpand all lines: vertexai/_genai/_evals_visualization.py
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,20 @@ def _extract_dataset_rows(dataset: types.EvaluationDataset) -> list[dict[str, An
228228
}
229229
processed_rows.append(processed_row)
230230

231+
for row in processed_rows:
232+
if isinstance(row["agent_data"], str) or not isinstance(
233+
row["intermediate_events"], str
234+
):
235+
continue
236+
try:
237+
events = json.loads(row["intermediate_events"])
238+
except json.JSONDecodeError:
239+
continue
240+
if isinstance(events, list) and events:
241+
row["agent_data"] = json.dumps(
242+
{"turns": [{"turn_index": 0, "events": events}]}, ensure_ascii=False
243+
)
244+
231245
return processed_rows
232246

233247

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.