@@ -32,7 +32,7 @@ class StreamingResponseAggregator:
3232 individual (partial) model responses, as well as for aggregated content.
3333 """
3434
35- def __init__ (self ):
35+ def __init__ (self ) -> None :
3636 self ._text = ''
3737 self ._thought_text = ''
3838 self ._usage_metadata = None
@@ -48,9 +48,9 @@ def __init__(self):
4848 self ._current_fc_name : Optional [str ] = None
4949 self ._current_fc_args : dict [str , Any ] = {}
5050 self ._current_fc_id : Optional [str ] = None
51- self ._current_thought_signature : Optional [str ] = None
51+ self ._current_thought_signature : Optional [bytes ] = None
5252
53- def _flush_text_buffer_to_sequence (self ):
53+ def _flush_text_buffer_to_sequence (self ) -> None :
5454 """Flush current text buffer to parts sequence.
5555
5656 This helper is used in progressive SSE mode to maintain part ordering.
@@ -70,7 +70,7 @@ def _flush_text_buffer_to_sequence(self):
7070
7171 def _get_value_from_partial_arg (
7272 self , partial_arg : types .PartialArg , json_path : str
73- ):
73+ ) -> tuple [ Any , bool ] :
7474 """Extract value from a partial argument.
7575
7676 Args:
@@ -80,7 +80,7 @@ def _get_value_from_partial_arg(
8080 Returns:
8181 Tuple of (value, has_value) where has_value indicates if a value exists
8282 """
83- value = None
83+ value : Any = None
8484 has_value = False
8585
8686 if partial_arg .string_value is not None :
@@ -95,12 +95,11 @@ def _get_value_from_partial_arg(
9595 path_parts = path_without_prefix .split ('.' )
9696
9797 # Try to get existing value
98- existing_value = self ._current_fc_args
98+ existing_value : Any = self ._current_fc_args
9999 for part in path_parts :
100100 if isinstance (existing_value , dict ) and part in existing_value :
101101 existing_value = existing_value [part ]
102102 else :
103- existing_value = None
104103 break
105104
106105 # Append to existing string or set new value
@@ -121,7 +120,7 @@ def _get_value_from_partial_arg(
121120
122121 return value , has_value
123122
124- def _set_value_by_json_path (self , json_path : str , value : Any ):
123+ def _set_value_by_json_path (self , json_path : str , value : Any ) -> None :
125124 """Set a value in _current_fc_args using JSONPath notation.
126125
127126 Args:
@@ -147,7 +146,7 @@ def _set_value_by_json_path(self, json_path: str, value: Any):
147146 # Set the final value
148147 current [path_parts [- 1 ]] = value
149148
150- def _flush_function_call_to_sequence (self ):
149+ def _flush_function_call_to_sequence (self ) -> None :
151150 """Flush current function call to parts sequence.
152151
153152 This creates a complete FunctionCall part from accumulated partial args.
@@ -175,7 +174,7 @@ def _flush_function_call_to_sequence(self):
175174 self ._current_fc_id = None
176175 self ._current_thought_signature = None
177176
178- def _process_streaming_function_call (self , fc : types .FunctionCall ):
177+ def _process_streaming_function_call (self , fc : types .FunctionCall ) -> None :
179178 """Process a streaming function call with partialArgs.
180179
181180 Args:
@@ -208,14 +207,14 @@ def _process_streaming_function_call(self, fc: types.FunctionCall):
208207 self ._flush_text_buffer_to_sequence ()
209208 self ._flush_function_call_to_sequence ()
210209
211- def _process_function_call_part (self , part : types .Part ):
210+ def _process_function_call_part (self , part : types .Part ) -> None :
212211 """Process a function call part (streaming or non-streaming).
213212
214213 Args:
215214 part: The part containing a function call
216215 """
217216 fc = part .function_call
218- if not fc :
217+ if fc is None :
219218 return
220219
221220 # Check if this is a streaming FC (has partialArgs or will_continue=True)
@@ -298,10 +297,11 @@ async def process_response(
298297 and llm_response .content .parts [0 ].text
299298 ):
300299 part0 = llm_response .content .parts [0 ]
300+ part_text = part0 .text or ''
301301 if part0 .thought :
302- self ._thought_text += part0 . text
302+ self ._thought_text += part_text
303303 else :
304- self ._text += part0 . text
304+ self ._text += part_text
305305 llm_response .partial = True
306306 elif (self ._thought_text or self ._text ) and (
307307 not llm_response .content
@@ -382,3 +382,5 @@ def close(self) -> Optional[LlmResponse]:
382382 else candidate .finish_message ,
383383 usage_metadata = self ._usage_metadata ,
384384 )
385+
386+ return None
0 commit comments