File tree Expand file tree Collapse file tree
src/google/adk/evaluation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -626,7 +626,7 @@ def convert_events_to_eval_invocations(
626626 invocations = []
627627 for invocation_id , events in events_by_invocation_id .items ():
628628 final_response = None
629- final_event = None
629+ final_event : Optional [ Event ] = None
630630 user_content = Content (parts = [])
631631 invocation_timestamp = 0
632632 app_details = None
@@ -636,7 +636,7 @@ def convert_events_to_eval_invocations(
636636 ):
637637 app_details = app_details_per_invocation [invocation_id ]
638638
639- events_to_add = []
639+ events_to_add : list [ Event ] = []
640640
641641 for event in events :
642642 current_author = (event .author or _DEFAULT_AUTHOR ).lower ()
@@ -670,7 +670,11 @@ def convert_events_to_eval_invocations(
670670
671671 invocation_events = []
672672 for e in events_to_add :
673- if e is final_event and not e .grounding_metadata :
673+ if (
674+ final_event is not None
675+ and e is final_event
676+ and not e .grounding_metadata
677+ ):
674678 continue
675679 invocation_events .append (
676680 InvocationEvent (
Original file line number Diff line number Diff line change 1717import enum
1818import statistics
1919from typing import Any
20+ from typing import cast
2021from typing import Optional
2122from typing import Union
2223
@@ -224,11 +225,14 @@ def get_grounding_metadata_as_json_str(
224225 if not grounding_metadata :
225226 return "No grounding metadata was provided."
226227
227- return _GroundingMetadataEntries (
228- grounding_metadata = grounding_metadata
229- ).model_dump_json (
230- indent = 2 ,
231- exclude_unset = True ,
232- exclude_defaults = True ,
233- exclude_none = True ,
228+ return cast (
229+ str ,
230+ _GroundingMetadataEntries (
231+ grounding_metadata = grounding_metadata
232+ ).model_dump_json (
233+ indent = 2 ,
234+ exclude_unset = True ,
235+ exclude_defaults = True ,
236+ exclude_none = True ,
237+ ),
234238 )
You can’t perform that action at this time.
0 commit comments