Fix linting

This commit is contained in:
yangdx 2025-07-08 18:17:21 +08:00
parent 8cbba6e9db
commit 2a0cff3ed6

View File

@ -218,7 +218,9 @@ async def openai_complete_if_cache(
# Check if this chunk has usage information (final chunk)
if hasattr(chunk, "usage") and chunk.usage:
final_chunk_usage = chunk.usage
logger.debug(f"Received usage info in streaming chunk: {chunk.usage}")
logger.debug(
f"Received usage info in streaming chunk: {chunk.usage}"
)
# Check if choices exists and is not empty
if not hasattr(chunk, "choices") or not chunk.choices:
@ -245,7 +247,9 @@ async def openai_complete_if_cache(
# Use actual usage from the API
token_counts = {
"prompt_tokens": getattr(final_chunk_usage, "prompt_tokens", 0),
"completion_tokens": getattr(final_chunk_usage, "completion_tokens", 0),
"completion_tokens": getattr(
final_chunk_usage, "completion_tokens", 0
),
"total_tokens": getattr(final_chunk_usage, "total_tokens", 0),
}
token_tracker.add_usage(token_counts)