Ignore None 'completion_tokens' or similar

Similar as 144ea36c81 , reported in https://github.com/pipecat-ai/pipecat/issues/2207
This commit is contained in:
LucasStringPay
2025-10-02 15:16:11 -07:00
committed by GitHub
parent 4abe4a6253
commit 607e3040d4

View File

@@ -94,9 +94,9 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService):
async for chunk in chunk_stream:
if chunk.usage:
tokens = LLMTokenUsage(
prompt_tokens=chunk.usage.prompt_tokens,
completion_tokens=chunk.usage.completion_tokens,
total_tokens=chunk.usage.total_tokens,
prompt_tokens=chunk.usage.prompt_tokens or 0,
completion_tokens=chunk.usage.completion_tokens or 0,
total_tokens=chunk.usage.total_tokens or 0,
)
await self.start_llm_usage_metrics(tokens)