yangdx
commited on
Commit
·
b59915a
1
Parent(s):
91d4317
Fix linting
Browse files- lightrag/llm/openai.py +9 -5
lightrag/llm/openai.py
CHANGED
@@ -201,14 +201,18 @@ async def openai_complete_if_cache(
|
|
201 |
try:
|
202 |
async for chunk in response:
|
203 |
# Check if choices exists and is not empty
|
204 |
-
if not hasattr(chunk,
|
205 |
logger.warning(f"Received chunk without choices: {chunk}")
|
206 |
continue
|
207 |
-
|
208 |
# Check if delta exists and has content
|
209 |
-
if not hasattr(chunk.choices[0],
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
212 |
content = chunk.choices[0].delta.content
|
213 |
if content is None:
|
214 |
continue
|
|
|
201 |
try:
|
202 |
async for chunk in response:
|
203 |
# Check if choices exists and is not empty
|
204 |
+
if not hasattr(chunk, "choices") or not chunk.choices:
|
205 |
logger.warning(f"Received chunk without choices: {chunk}")
|
206 |
continue
|
207 |
+
|
208 |
# Check if delta exists and has content
|
209 |
+
if not hasattr(chunk.choices[0], "delta") or not hasattr(
|
210 |
+
chunk.choices[0].delta, "content"
|
211 |
+
):
|
212 |
+
logger.warning(
|
213 |
+
f"Received chunk without delta content: {chunk.choices[0]}"
|
214 |
+
)
|
215 |
+
continue
|
216 |
content = chunk.choices[0].delta.content
|
217 |
if content is None:
|
218 |
continue
|