Also included a token_usage sample that showcases the token usage of subagents with different models under a parent agent.
PiperOrigin-RevId: 759347015
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
The old implementation:
1. We only started transcription at the beginning of agent transferring.
2. The transcription service we used is not as good / fast as the model/native transcription.
In the current implementation, the live agent will rely on the llm's transcription, instead of our transcription when llm support audio transcription in the input. And in that case, the live agent won't use our own audio transcriber. This reduces the latency from 5secs to 2 secs during agent transferring. It also improves the transcription quality.
When the llm doesn't support audio transcription, we still use our audio transcriber to transcribe audio input.
PiperOrigin-RevId: 758296647
(before/after) tool callbacks are invoked throughout the provided chain until one callback does not return None. Callbacks can be async and sync.
PiperOrigin-RevId: 756526507
(before/after) agent callbacks are invoked throughout the provided chain until one callback does not return None. Callbacks can be async and sync.
PiperOrigin-RevId: 756359693
(before/after) model callbacks are invoked throughout the provided chain until one callback does not return None. Callbacks can be async and sync.
PiperOrigin-RevId: 755565583
Copybara import of the project:
--
d481e0604a79470e2c1308827b3ecb78bfb5327e by Alan B <alan@nerds.ai>:
feat: 🚧 catch user transcription
--
bba436bb76d1d2f9d5ba969fce38ff8b8a443254 by Alan B <alan@nerds.ai>:
feat: ✨ send user transcription event as llm_response
--
ad2abf540c60895b79c50f9051a6289ce394b98d by Alan B <death1027@outlook.com>:
style: 💄 update lint problems
--
744703c06716300c0f9f41633d3bafdf4cb180a1 by Hangfei Lin <hangfeilin@gmail.com>:
fix: set right order for input transcription
--
31a5d42d6155b0e5caad0c73c8df43255322016f by Hangfei Lin <hangfeilin@gmail.com>:
remove print
--
59e5d9c72060f97d124883150989315401a4c1b5 by Hangfei Lin <hangfeilin@gmail.com>:
remove api version
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/495 from BloodBoy21:main ea29015af041f9785abaa8583e2c767f9d8c8bc8
PiperOrigin-RevId: 755401615
--
ad923c2c8c503ba73c62db695e88f1a3ea1aeeea by YU MING HSU <abego452@gmail.com>:
docs: enhance Contribution process within CONTRIBUTING.md
--
8022924fb7e975ac278d38fce3b5fd593d874536 by YU MING HSU <abego452@gmail.com>:
fix: move _maybe_append_user_content from google_llm.py to base_llm.py,
so subclass can get benefit from it, call _maybe_append_user_content
from generate_content_async within lite_llm.py
--
cf891fb1a3bbccaaf9d0055b23f614ce52449977 by YU MING HSU <abego452@gmail.com>:
fix: modify install dependencies cmd, and use pyink to format codebase
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/428 from hsuyuming:fix_litellm_error_issue_427 dbec4949798e6399a0410d1b8ba7cc6a7cad7bdd
PiperOrigin-RevId: 754124679
--
21736067f9 by Alankrit Verma <alankrit386@gmail.com>:
feat(llm_flows): support async before/after tool callbacks
Previously, callbacks were treated as purely synchronous,
so passing an async coroutine caused “was never awaited”
errors and Pydantic serialization failures.
Now we detect awaitable return values from
before_tool_callback and after_tool_callback,
and `await` them if necessary.
Fixes: #380
--
08ac9a117e by Alankrit Verma <alankrit386@gmail.com>:
Refactor function callback handling and update type signatures
- Simplify variable names in `functions.py`: always use `function_response` and `altered_function_response`
- Update LlmAgent callback type aliases to support async:
- Import `Awaitable`
- Change `BeforeToolCallback` and `AfterToolCallback` signatures to return `Awaitable[Optional[dict]]`
- Ensure `after_tool_callback` uses `await` when necessary
--
fcbf57466e by Alankrit Verma <alankrit386@gmail.com>:
refactor: update callback type signatures to support sync and async responses
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/434 from AlankritVerma01:support-async-tool-callbacks 926b0ef1a6
PiperOrigin-RevId: 753005846
--
16994cb2d5d646341f5285ca71d72697d81d18fe by Nilanjan De <nilanjan.de@gmail.com>:
chore: fix typos
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/272 from n1lanjan:fix-typos a1ab655b08ec08c5dd2da71aab9a2386e3610e84
PiperOrigin-RevId: 749690489