From 467184e63e6c095d227d766c541a416be6053db0 Mon Sep 17 00:00:00 2001 From: Vittorio Palmisano <283319+vpalmisano@users.noreply.github.com> Date: Thu, 26 Mar 2026 13:09:36 +0100 Subject: [PATCH 1/2] Fix audio transcript check in base_llm.py In some cases the openai provider could answer with a `chunk.choices[0].delta.audio = None`, so the process context fails with error: ``` pipecat/services/openai/base_llm.py:552): Error during completion: 'NoneType' object has no attribute 'get' ``` --- src/pipecat/services/openai/base_llm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index 53de03d09..a842da141 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -545,7 +545,7 @@ class BaseOpenAILLMService(LLMService): # When gpt-4o-audio / gpt-4o-mini-audio is used for llm or stt+llm # we need to get LLMTextFrame for the transcript - elif hasattr(chunk.choices[0].delta, "audio") and chunk.choices[0].delta.audio.get( + elif hasattr(chunk.choices[0].delta, "audio") and chunk.choices[0].delta.audio and chunk.choices[0].delta.audio.get( "transcript" ): await self.push_frame(LLMTextFrame(chunk.choices[0].delta.audio["transcript"])) From 537d57449ee527e06bb03cbb85491ed9d7282452 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Fri, 27 Mar 2026 09:29:46 -0300 Subject: [PATCH 2/2] Fixing the format and including the changelog. --- changelog/4152.fixed.md | 1 + src/pipecat/services/openai/base_llm.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog/4152.fixed.md diff --git a/changelog/4152.fixed.md b/changelog/4152.fixed.md new file mode 100644 index 000000000..e752bb1ac --- /dev/null +++ b/changelog/4152.fixed.md @@ -0,0 +1 @@ +- Fixed a crash in OpenAI LLM processing when the provider returns `chunk.choices[0].delta.audio = None`, which caused `'NoneType' object has no attribute 'get'` errors during audio transcript handling. diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index a842da141..dfee6d6f3 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -545,8 +545,10 @@ class BaseOpenAILLMService(LLMService): # When gpt-4o-audio / gpt-4o-mini-audio is used for llm or stt+llm # we need to get LLMTextFrame for the transcript - elif hasattr(chunk.choices[0].delta, "audio") and chunk.choices[0].delta.audio and chunk.choices[0].delta.audio.get( - "transcript" + elif ( + hasattr(chunk.choices[0].delta, "audio") + and chunk.choices[0].delta.audio + and chunk.choices[0].delta.audio.get("transcript") ): await self.push_frame(LLMTextFrame(chunk.choices[0].delta.audio["transcript"]))