Fix linting

This commit is contained in:
yangdx
2025-04-20 11:17:51 +08:00
parent da09de1361
commit a418b18ed1

View File

@@ -201,13 +201,17 @@ async def openai_complete_if_cache(
try: try:
async for chunk in response: async for chunk in response:
# 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:
logger.warning(f"Received chunk without choices: {chunk}") logger.warning(f"Received chunk without choices: {chunk}")
continue continue
# Check if delta exists and has content # Check if delta exists and has content
if not hasattr(chunk.choices[0], 'delta') or not hasattr(chunk.choices[0].delta, 'content'): if not hasattr(chunk.choices[0], "delta") or not hasattr(
logger.warning(f"Received chunk without delta content: {chunk.choices[0]}") chunk.choices[0].delta, "content"
):
logger.warning(
f"Received chunk without delta content: {chunk.choices[0]}"
)
continue continue
content = chunk.choices[0].delta.content content = chunk.choices[0].delta.content
if content is None: if content is None: