[bug]TypeError: object of type 'NoneType' has no len()

Sometimes the chunk.choices is None, and I got exception like: 
```
TypeError: object of type 'NoneType' has no len()
```
This commit is contained in:
Cheng Hao
2025-01-22 15:31:27 +08:00
committed by GitHub
parent 0d79a9eaa6
commit 7e8fc2e7e2

View File

@@ -221,7 +221,7 @@ class BaseOpenAILLMService(LLMService):
)
await self.start_llm_usage_metrics(tokens)
if len(chunk.choices) == 0:
if chunk.choices is None or len(chunk.choices) == 0:
continue
await self.stop_ttfb_metrics()