Merge pull request #2779 from LucasStringPay/patch-1

Ignore None value for 'completion_tokens' or similar for Gemini
This commit is contained in:
Aleix Conchillo Flaqué
2025-10-09 16:55:33 -07:00
committed by GitHub

View File

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