From 8fc76a29bc2841e0b6f7ce2a111a20f6d29ec569 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Mon, 18 Aug 2025 11:08:40 -0400 Subject: [PATCH] Raise errors when trying to use universal `LLMContext` with LLM services that don't yet support it --- src/pipecat/services/anthropic/llm.py | 3 +++ src/pipecat/services/aws/llm.py | 3 +++ src/pipecat/services/aws_nova_sonic/aws.py | 5 +++++ src/pipecat/services/openai_realtime_beta/openai.py | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/src/pipecat/services/anthropic/llm.py b/src/pipecat/services/anthropic/llm.py index 3a26519f6..8b25fd2d5 100644 --- a/src/pipecat/services/anthropic/llm.py +++ b/src/pipecat/services/anthropic/llm.py @@ -31,6 +31,7 @@ from pipecat.frames.frames import ( FunctionCallCancelFrame, FunctionCallInProgressFrame, FunctionCallResultFrame, + LLMContextFrame, LLMEnablePromptCachingFrame, LLMFullResponseEndFrame, LLMFullResponseStartFrame, @@ -408,6 +409,8 @@ class AnthropicLLMService(LLMService): context = None if isinstance(frame, OpenAILLMContextFrame): context: "AnthropicLLMContext" = AnthropicLLMContext.upgrade_to_anthropic(frame.context) + elif isinstance(frame, LLMContextFrame): + raise NotImplementedError("Universal LLMContext is not yet supported for Anthropic.") elif isinstance(frame, LLMMessagesFrame): context = AnthropicLLMContext.from_messages(frame.messages) elif isinstance(frame, VisionImageRawFrame): diff --git a/src/pipecat/services/aws/llm.py b/src/pipecat/services/aws/llm.py index a4e1366c2..87771b03b 100644 --- a/src/pipecat/services/aws/llm.py +++ b/src/pipecat/services/aws/llm.py @@ -31,6 +31,7 @@ from pipecat.frames.frames import ( FunctionCallFromLLM, FunctionCallInProgressFrame, FunctionCallResultFrame, + LLMContextFrame, LLMFullResponseEndFrame, LLMFullResponseStartFrame, LLMMessagesFrame, @@ -1044,6 +1045,8 @@ class AWSBedrockLLMService(LLMService): context = None if isinstance(frame, OpenAILLMContextFrame): context = AWSBedrockLLMContext.upgrade_to_bedrock(frame.context) + if isinstance(frame, LLMContextFrame): + raise NotImplementedError("Universal LLMContext is not yet supported for AWS Bedrock.") elif isinstance(frame, LLMMessagesFrame): context = AWSBedrockLLMContext.from_messages(frame.messages) elif isinstance(frame, VisionImageRawFrame): diff --git a/src/pipecat/services/aws_nova_sonic/aws.py b/src/pipecat/services/aws_nova_sonic/aws.py index 6ca6c9f61..acc76f1ce 100644 --- a/src/pipecat/services/aws_nova_sonic/aws.py +++ b/src/pipecat/services/aws_nova_sonic/aws.py @@ -34,6 +34,7 @@ from pipecat.frames.frames import ( FunctionCallFromLLM, InputAudioRawFrame, InterimTranscriptionFrame, + LLMContextFrame, LLMFullResponseEndFrame, LLMFullResponseStartFrame, LLMTextFrame, @@ -322,6 +323,10 @@ class AWSNovaSonicLLMService(LLMService): if isinstance(frame, OpenAILLMContextFrame): await self._handle_context(frame.context) + elif isinstance(frame, LLMContextFrame): + raise NotImplementedError( + "Universal LLMContext is not yet supported for AWS Nova Sonic." + ) elif isinstance(frame, InputAudioRawFrame): await self._handle_input_audio_frame(frame) elif isinstance(frame, BotStoppedSpeakingFrame): diff --git a/src/pipecat/services/openai_realtime_beta/openai.py b/src/pipecat/services/openai_realtime_beta/openai.py index bc7af9a46..dd22694f7 100644 --- a/src/pipecat/services/openai_realtime_beta/openai.py +++ b/src/pipecat/services/openai_realtime_beta/openai.py @@ -23,6 +23,7 @@ from pipecat.frames.frames import ( Frame, InputAudioRawFrame, InterimTranscriptionFrame, + LLMContextFrame, LLMFullResponseEndFrame, LLMFullResponseStartFrame, LLMMessagesAppendFrame, @@ -343,6 +344,10 @@ class OpenAIRealtimeBetaLLMService(LLMService): await self.reset_conversation() # Run the LLM at next opportunity await self._create_response() + elif isinstance(frame, LLMContextFrame): + raise NotImplementedError( + "Universal LLMContext is not yet supported for OpenAI Realtime." + ) elif isinstance(frame, InputAudioRawFrame): if not self._audio_input_paused: await self._send_user_audio(frame)