From 6838bc1e51eec72c7c4285c21dbdf18fb975159a Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Tue, 2 Sep 2025 15:52:44 -0400 Subject: [PATCH] Add a few missing `LLMContext` type hints --- src/pipecat/services/grok/llm.py | 3 ++- src/pipecat/services/nim/llm.py | 3 ++- src/pipecat/services/perplexity/llm.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/grok/llm.py b/src/pipecat/services/grok/llm.py index 2a9704008..684be2d39 100644 --- a/src/pipecat/services/grok/llm.py +++ b/src/pipecat/services/grok/llm.py @@ -16,6 +16,7 @@ from dataclasses import dataclass from loguru import logger from pipecat.metrics.metrics import LLMTokenUsage +from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.llm_response import ( LLMAssistantAggregatorParams, LLMUserAggregatorParams, @@ -107,7 +108,7 @@ class GrokLLMService(OpenAILLMService): logger.debug(f"Creating Grok client with api {base_url}") return super().create_client(api_key, base_url, **kwargs) - async def _process_context(self, context: OpenAILLMContext): + async def _process_context(self, context: OpenAILLMContext | LLMContext): """Process a context through the LLM and accumulate token usage metrics. This method overrides the parent class implementation to handle Grok's diff --git a/src/pipecat/services/nim/llm.py b/src/pipecat/services/nim/llm.py index 052b94274..07e970521 100644 --- a/src/pipecat/services/nim/llm.py +++ b/src/pipecat/services/nim/llm.py @@ -11,6 +11,7 @@ Microservice) API while maintaining compatibility with the OpenAI-style interfac """ 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.openai.llm import OpenAILLMService @@ -47,7 +48,7 @@ class NimLLMService(OpenAILLMService): self._has_reported_prompt_tokens = False self._is_processing = False - async def _process_context(self, context: OpenAILLMContext): + async def _process_context(self, context: OpenAILLMContext | LLMContext): """Process a context through the LLM and accumulate token usage metrics. This method overrides the parent class implementation to handle NVIDIA's diff --git a/src/pipecat/services/perplexity/llm.py b/src/pipecat/services/perplexity/llm.py index bc4b220ac..814699070 100644 --- a/src/pipecat/services/perplexity/llm.py +++ b/src/pipecat/services/perplexity/llm.py @@ -15,6 +15,7 @@ from openai import NOT_GIVEN from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams 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.openai.llm import OpenAILLMService @@ -84,7 +85,7 @@ class PerplexityLLMService(OpenAILLMService): return params - async def _process_context(self, context: OpenAILLMContext): + async def _process_context(self, context: OpenAILLMContext | LLMContext): """Process a context through the LLM and accumulate token usage metrics. This method overrides the parent class implementation to handle