From e04f42167e2e06e40de648422318223412590ee7 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Tue, 2 Sep 2025 15:40:15 -0400 Subject: [PATCH] Add support for universal `LLMContext` to SambaNova LLM service --- src/pipecat/services/sambanova/llm.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index d39eb51a2..5ed600457 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -18,6 +18,7 @@ from pipecat.frames.frames import ( LLMTextFrame, ) from pipecat.metrics.metrics import LLMTokenUsage +from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.services.llm_service import FunctionCallFromLLM from pipecat.services.openai.llm import OpenAILLMService @@ -99,7 +100,9 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore return params @traced_llm # type: ignore - async def _process_context(self, context: OpenAILLMContext) -> AsyncStream[ChatCompletionChunk]: + async def _process_context( + self, context: OpenAILLMContext | LLMContext + ) -> AsyncStream[ChatCompletionChunk]: """Process OpenAI LLM context and stream chat completion chunks. This method handles the streaming response from SambaNova API, including @@ -122,9 +125,11 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore await self.start_ttfb_metrics() - chunk_stream: AsyncStream[ - ChatCompletionChunk - ] = await self._stream_chat_completions_specific_context(context) + chunk_stream = await ( + self._stream_chat_completions_specific_context(context) + if isinstance(context, OpenAILLMContext) + else self._stream_chat_completions_universal_context(context) + ) async for chunk in chunk_stream: if chunk.usage: @@ -210,12 +215,3 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore ) await self.run_function_calls(function_calls) - - @property - def supports_universal_context(self) -> bool: - """Check if this service supports universal LLMContext. - - Returns: - False, as SambaNovaLLMService does not yet support universal LLMContext. - """ - return False