From a418b18ed13d0af5bd3925fdb3475b013bafd016 Mon Sep 17 00:00:00 2001 From: yangdx Date: Sun, 20 Apr 2025 11:17:51 +0800 Subject: [PATCH] Fix linting --- lightrag/llm/openai.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lightrag/llm/openai.py b/lightrag/llm/openai.py index 9fbec5e1..9cd0dc83 100644 --- a/lightrag/llm/openai.py +++ b/lightrag/llm/openai.py @@ -201,14 +201,18 @@ async def openai_complete_if_cache( try: async for chunk in response: # 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}") continue - + # Check if delta exists and has content - if not hasattr(chunk.choices[0], 'delta') or not hasattr(chunk.choices[0].delta, 'content'): - logger.warning(f"Received chunk without delta content: {chunk.choices[0]}") - continue + if not hasattr(chunk.choices[0], "delta") or not hasattr( + chunk.choices[0].delta, "content" + ): + logger.warning( + f"Received chunk without delta content: {chunk.choices[0]}" + ) + continue content = chunk.choices[0].delta.content if content is None: continue