From 537d57449ee527e06bb03cbb85491ed9d7282452 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Fri, 27 Mar 2026 09:29:46 -0300 Subject: [PATCH] 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"]))