Skip to content

Commit 68afef3

Browse files
authored
fix(evaluate): 1.fix evalset parse. 2.fix save_eval_set (#291)
1 parent 4623971 commit 68afef3

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

veadk/evaluation/base_evaluator.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,10 @@ def build_eval_set(
442442
_input = user_content.parts[0].text
443443
_expected_output = invocation.final_response.parts[0].text
444444

445-
if invocation.intermediate_data.tool_uses:
445+
if (
446+
hasattr(invocation.intermediate_data, "tool_uses")
447+
and invocation.intermediate_data.tool_uses
448+
):
446449
for expected_tool_use in invocation.intermediate_data.tool_uses:
447450
_expected_tool.append(
448451
{
@@ -451,6 +454,26 @@ def build_eval_set(
451454
}
452455
)
453456

457+
elif (
458+
hasattr(invocation.intermediate_data, "invocation_events")
459+
and invocation.intermediate_data.invocation_events
460+
):
461+
for event in invocation.intermediate_data.invocation_events:
462+
if hasattr(event, "content") and hasattr(
463+
event.content, "parts"
464+
):
465+
for part in event.content.parts:
466+
if (
467+
hasattr(part, "function_call")
468+
and part.function_call is not None
469+
):
470+
_expected_tool.append(
471+
{
472+
"name": part.function_call.name,
473+
"args": part.function_call.args,
474+
}
475+
)
476+
454477
eval_case_data.invocations.append(
455478
Invocation(
456479
invocation_id=invocation.invocation_id,

veadk/evaluation/eval_set_recorder.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import time
1616
from pathlib import Path
17-
17+
import os
1818
from google.adk.cli.utils import evals
1919
from google.adk.evaluation.eval_case import EvalCase, SessionInput
2020
from google.adk.evaluation.local_eval_sets_manager import LocalEvalSetsManager
@@ -131,7 +131,8 @@ async def dump(
131131
dump_path = self._get_eval_set_file_path(app_name, self.eval_set_id)
132132
Path(dump_path).parent.mkdir(parents=True, exist_ok=True)
133133

134-
self.create_eval_set(app_name=app_name, eval_set_id=self.eval_set_id)
134+
if not os.path.exists(dump_path):
135+
self.create_eval_set(app_name=app_name, eval_set_id=self.eval_set_id)
135136

136137
await self.add_session_to_eval_set(
137138
app_name=app_name,

0 commit comments

Comments
 (0)