-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
We are using the Gemini Realtime model. After upgrading to 1.0.21, we started seeing the following error immediately proceeding any function_tool invocation:
2025-05-21 13:40:42,333 - ERROR livekit.plugins.google - error in receive task: unsupported operand type(s) for +=: 'int' and 'NoneType'
Traceback (most recent call last):
.\livekit\plugins\google\beta\realtime\realtime_api.py", line 571, in _recv_task
self._handle_usage_metadata(response.usage_metadata)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
.\livekit\plugins\google\beta\realtime\realtime_api.py", line 822, in _handle_usage_metadata
**_token_details_map(usage_metadata.response_tokens_details),
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.\livekit\plugins\google\beta\realtime\realtime_api.py", line 793, in _token_details_map
token_details_map["audio_tokens"] += token_detail.token_count
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'
This error is caused by token_detail.token_count
being None
in the usage metadata returned by the model.
I believe this was introduced in #2275.
A simple fix is ensure token_count
is defined before attempting to update the token_details_map. I'll open a PR to this effect, but if there's a deeper cause/better fix please let me know.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working