From 3a745bfa3f2765b7d17ff1252ff2d80d9b35dc62 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Mon, 7 Oct 2024 13:26:48 -0400 Subject: [PATCH] Handle self._context of None --- src/pipecat/services/openai_realtime_beta/llm_and_context.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pipecat/services/openai_realtime_beta/llm_and_context.py b/src/pipecat/services/openai_realtime_beta/llm_and_context.py index d4cb155bf..b79e549af 100644 --- a/src/pipecat/services/openai_realtime_beta/llm_and_context.py +++ b/src/pipecat/services/openai_realtime_beta/llm_and_context.py @@ -211,7 +211,10 @@ class OpenAILLMServiceRealtimeBeta(LLMService): elif evt.type == "conversation.item.input_audio_transcription.completed": # or here maybe (possible send upstream to user context aggregator) if evt.transcript: - self._context.add_message({"role": "user", "content": evt.transcript}) + if self._context: + self._context.add_message({"role": "user", "content": evt.transcript}) + else: + logger.error("Context is None, cannot add message") elif evt.type == "response.output_item.added": # todo: think about adding a frame for this (generally, in Pipecat/RTVI), as # it could be useful for managing UI state