@@ -106,10 +106,6 @@ def _find_active_task_isolation_scope(session) -> Optional[str]:
106106 return None
107107
108108
109- def _is_tool_call_or_response (event : Event ) -> bool :
110- return bool (event .get_function_calls () or event .get_function_responses ())
111-
112-
113109def _get_function_responses_from_content (
114110 content : types .Content ,
115111) -> list [types .FunctionResponse ]:
@@ -120,21 +116,6 @@ def _get_function_responses_from_content(
120116 ]
121117
122118
123- def _is_transcription (event : Event ) -> bool :
124- return (
125- event .input_transcription is not None
126- or event .output_transcription is not None
127- )
128-
129-
130- def _has_non_empty_transcription_text (
131- transcription : types .Transcription ,
132- ) -> bool :
133- return bool (
134- transcription and transcription .text and transcription .text .strip ()
135- )
136-
137-
138119def _apply_run_config_custom_metadata (
139120 event : Event , run_config : RunConfig | None
140121) -> None :
@@ -1404,22 +1385,6 @@ async def _exec_with_plugin(
14041385 yield early_exit_event
14051386 else :
14061387 # Step 2: Otherwise continue with normal execution
1407- # Note for live/bidi:
1408- # the transcription may arrive later than the action(function call
1409- # event and thus function response event). In this case, the order of
1410- # transcription and function call event will be wrong if we just
1411- # append as it arrives. To address this, we should check if there is
1412- # transcription going on. If there is transcription going on, we
1413- # should hold on appending the function call event until the
1414- # transcription is finished. The transcription in progress can be
1415- # identified by checking if the transcription event is partial. When
1416- # the next transcription event is not partial, it means the previous
1417- # transcription is finished. Then if there is any buffered function
1418- # call event, we should append them after this finished(non-partial)
1419- # transcription event.
1420- buffered_events : list [Event ] = []
1421- is_transcribing : bool = False
1422-
14231388 async with aclosing (execute_fn (invocation_context )) as agen :
14241389 async for event in agen :
14251390 _apply_run_config_custom_metadata (
@@ -1437,50 +1402,14 @@ async def _exec_with_plugin(
14371402 )
14381403
14391404 if is_live_call :
1440- if event .partial and _is_transcription (event ):
1441- is_transcribing = True
1442- if is_transcribing and _is_tool_call_or_response (event ):
1443- # only buffer function call and function response event which is
1444- # non-partial
1445- buffered_events .append (output_event )
1446- continue
1447- # Note for live/bidi: for audio response, it's considered as
1448- # non-partial event(event.partial=None)
1449- # event.partial=False and event.partial=None are considered as
1450- # non-partial event; event.partial=True is considered as partial
1451- # event.
1452- if event .partial is not True :
1453- if _is_transcription (event ) and (
1454- _has_non_empty_transcription_text (event .input_transcription )
1455- or _has_non_empty_transcription_text (
1456- event .output_transcription
1457- )
1458- ):
1459- # transcription end signal, append buffered events
1460- is_transcribing = False
1461- logger .debug (
1462- 'Appending transcription finished event: %s' , event
1463- )
1464- if self ._should_append_event (event , is_live_call ):
1465- await self .session_service .append_event (
1466- session = invocation_context .session , event = output_event
1467- )
1468-
1469- for buffered_event in buffered_events :
1470- logger .debug ('Appending buffered event: %s' , buffered_event )
1471- await self .session_service .append_event (
1472- session = invocation_context .session , event = buffered_event
1473- )
1474- yield buffered_event # yield buffered events to caller
1475- buffered_events = []
1476- else :
1477- # non-transcription event or empty transcription event, for
1478- # example, event that stores blob reference, should be appended.
1479- if self ._should_append_event (event , is_live_call ):
1480- logger .debug ('Appending non-buffered event: %s' , event )
1481- await self .session_service .append_event (
1482- session = invocation_context .session , event = output_event
1483- )
1405+ # Skip partial transcriptions for Live
1406+ if event .partial is not True and self ._should_append_event (
1407+ event , is_live_call
1408+ ):
1409+ logger .debug ('Appending live event: %s' , output_event )
1410+ await self .session_service .append_event (
1411+ session = invocation_context .session , event = output_event
1412+ )
14841413 else :
14851414 if event .partial is not True :
14861415 await self .session_service .append_event (
0 commit comments