Add support for universal LLMContext to SambaNova LLM service
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user