input_tokens could be None when calculate ussage (Anthropic service)
pipecat version
0.0.67
Python version
3.11
Operating System
mac
Issue description
2025-05-20 16:56:23.768 | ERROR | pipecat.services.anthropic.llm:_process_context:260 - input_tokens为None,原始event: RawMessageDeltaEvent(delta=Delta(stop_reason='end_turn', stop_sequence=None), type='message_delta', usage=MessageDeltaUsage(cache_creation_input_tokens=None, cache_read_input_tokens=None, input_tokens=None, output_tokens=98, server_tool_use=None)) 2025-05-20 16:56:23.768 | ERROR | pipecat.services.anthropic.llm:_process_context:316 - API调用异常: unsupported operand type(s) for +=: 'int' and 'NoneType'
Reproduction steps
^
Expected behavior
^
Actual behavior
^
Logs
unsupported operand type(s) for +=: 'int' and 'NoneType'
Change event.usage.input_tokens if hasattr(event.usage, "input_tokens") else 0
To event.usage.input_tokens if (hasattr(event.usage, "input_tokens") and event.usage.input_tokens is not None) else 0
will fix
In what scenario does this happen? It would be helpful if you add repro steps.