From 7e8fc2e7e253b103ef22f0a7a2ef593629a0b99f Mon Sep 17 00:00:00 2001 From: Cheng Hao Date: Wed, 22 Jan 2025 15:31:27 +0800 Subject: [PATCH] [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() ``` --- src/pipecat/services/openai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pipecat/services/openai.py b/src/pipecat/services/openai.py index 19c8f6d99..1c3977b7f 100644 --- a/src/pipecat/services/openai.py +++ b/src/pipecat/services/openai.py @@ -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()