mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-12-25 14:37:45 -06:00
feat(live): Support live mode of sequential agent
Add a `task_completed` function to the agent so when a model finished the task, it can send a signal and the program knows it can go to next agent. This cl include: * Implements the `_run_live_impl` in `sequential_agent` so it can handle live case. * Add an example for sequential agent. * Improve error message for unimplemented _run_live_impl in other agents. Note: 1. Compared to non-live case, live agents process a continuous streams of audio or video, so it doesn't have a native way to tell if it's finished and should pass to next agent or not. So we introduce a task_compelted() function so the model can call this function to signal that it's finished the task and we can move on to next agent. 2. live agents doesn't seems to be very useful or natural in parallel or loop agents so we don't implement it for now. If there is user demand, we can implement it easily using similar approach. PiperOrigin-RevId: 758315430
This commit is contained in:
committed by
Copybara-Service
parent
39f78dc28f
commit
4188673b0f
@@ -135,6 +135,18 @@ class BaseLlmFlow(ABC):
|
||||
# cancel the tasks that belongs to the closed connection.
|
||||
send_task.cancel()
|
||||
await llm_connection.close()
|
||||
if (
|
||||
event.content
|
||||
and event.content.parts
|
||||
and event.content.parts[0].function_response
|
||||
and event.content.parts[0].function_response.name
|
||||
== 'task_completed'
|
||||
):
|
||||
# this is used for sequential agent to signal the end of the agent.
|
||||
await asyncio.sleep(1)
|
||||
# cancel the tasks that belongs to the closed connection.
|
||||
send_task.cancel()
|
||||
return
|
||||
finally:
|
||||
# Clean up
|
||||
if not send_task.done():
|
||||
@@ -237,7 +249,7 @@ class BaseLlmFlow(ABC):
|
||||
if (
|
||||
event.content
|
||||
and event.content.parts
|
||||
and event.content.parts[0].text
|
||||
and event.content.parts[0].inline_data is None
|
||||
and not event.partial
|
||||
):
|
||||
# This can be either user data or transcription data.
|
||||
|
||||
Reference in New Issue
Block a user