Skip to content

Commit 5cb35db

Browse files
ankursharmascopybara-github
authored andcommitted
chore: Avoid rendering empty columns as part of detailed results rendering of eval results
It is common for expected response and expected tool calls column to be empty for user simulated conversations. So, we don't render those. Co-authored-by: Ankur Sharma <ankusharma@google.com> PiperOrigin-RevId: 826202867
1 parent b8a2b6c commit 5cb35db

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/google/adk/cli/cli_eval.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,16 @@ def pretty_print_eval_result(eval_result: EvalCaseResult):
214214
expected_invocation = per_invocation_result.expected_invocation
215215
row_data = {
216216
"prompt": _convert_content_to_text(actual_invocation.user_content),
217-
"expected_response": _convert_content_to_text(
218-
expected_invocation.final_response if expected_invocation else None
217+
"expected_response": (
218+
_convert_content_to_text(expected_invocation.final_response)
219+
if expected_invocation
220+
else None
219221
),
220222
"actual_response": _convert_content_to_text(
221223
actual_invocation.final_response
222224
),
223-
"expected_tool_calls": _convert_tool_calls_to_text(
224-
expected_invocation.intermediate_data
225+
"expected_tool_calls": (
226+
_convert_tool_calls_to_text(expected_invocation.intermediate_data)
225227
if expected_invocation
226228
else None
227229
),
@@ -252,11 +254,23 @@ def pretty_print_eval_result(eval_result: EvalCaseResult):
252254
)
253255
click.echo("Invocation Details:")
254256
df = pd.DataFrame(data)
257+
258+
# Identify columns where ALL values are exactly None
259+
columns_to_keep = []
255260
for col in df.columns:
256-
if df[col].dtype == "object":
257-
df[col] = df[col].str.wrap(40)
258-
click.echo(tabulate(df, headers="keys", tablefmt="grid"))
259-
click.echo("\n\n") # Few empty lines for visual clarity
261+
# Check if all elements in the column are NOT None
262+
if not df[col].apply(lambda x: x is None).all():
263+
columns_to_keep.append(col)
264+
265+
# Select only the columns to keep
266+
df_result = df[columns_to_keep]
267+
268+
for col in df_result.columns:
269+
if df_result[col].dtype == "object":
270+
df_result[col] = df_result[col].str.wrap(40)
271+
272+
click.echo(tabulate(df_result, headers="keys", tablefmt="grid"))
273+
click.echo("\n\n") # Few empty lines for visual clarity
260274

261275

262276
def get_eval_sets_manager(

0 commit comments

Comments
 (0)