mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-12-14 08:20:55 +00:00
Fix linting
This commit is contained in:
parent
8cbba6e9db
commit
2a0cff3ed6
@ -218,7 +218,9 @@ async def openai_complete_if_cache(
|
|||||||
# Check if this chunk has usage information (final chunk)
|
# Check if this chunk has usage information (final chunk)
|
||||||
if hasattr(chunk, "usage") and chunk.usage:
|
if hasattr(chunk, "usage") and chunk.usage:
|
||||||
final_chunk_usage = 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
|
# Check if choices exists and is not empty
|
||||||
if not hasattr(chunk, "choices") or not chunk.choices:
|
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
|
# Use actual usage from the API
|
||||||
token_counts = {
|
token_counts = {
|
||||||
"prompt_tokens": getattr(final_chunk_usage, "prompt_tokens", 0),
|
"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),
|
"total_tokens": getattr(final_chunk_usage, "total_tokens", 0),
|
||||||
}
|
}
|
||||||
token_tracker.add_usage(token_counts)
|
token_tracker.add_usage(token_counts)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user