diff --git a/src/pipecat/adapters/services/anthropic_adapter.py b/src/pipecat/adapters/services/anthropic_adapter.py index 2baa341f1..0fc1636f7 100644 --- a/src/pipecat/adapters/services/anthropic_adapter.py +++ b/src/pipecat/adapters/services/anthropic_adapter.py @@ -91,7 +91,7 @@ class AnthropicLLMAdapter(BaseLLMAdapter[AnthropicLLMInvocationParams]): self.get_messages(context), system_instruction=system_instruction ) system = self._resolve_system_instruction( - converted.system if converted.system is not NOT_GIVEN else None, + converted.system if is_given(converted.system) else None, system_instruction, discard_context_system=True, ) diff --git a/src/pipecat/services/openai/llm.py b/src/pipecat/services/openai/llm.py index 21894b93c..9e9b35d83 100644 --- a/src/pipecat/services/openai/llm.py +++ b/src/pipecat/services/openai/llm.py @@ -8,6 +8,7 @@ from openai import NOT_GIVEN +from pipecat.adapters.services.open_ai_adapter import is_given from pipecat.services.openai.base_llm import BaseOpenAILLMService @@ -71,7 +72,7 @@ class OpenAILLMService(BaseOpenAILLMService): default_settings.model = model # Handle service_tier from deprecated params - if params is not None and not settings and params.service_tier is not NOT_GIVEN: + if params is not None and not settings and is_given(params.service_tier): service_tier = service_tier or params.service_tier # 3. Apply params overrides — only if settings not provided diff --git a/src/pipecat/services/sarvam/llm.py b/src/pipecat/services/sarvam/llm.py index 224b2da43..1e82cdbda 100644 --- a/src/pipecat/services/sarvam/llm.py +++ b/src/pipecat/services/sarvam/llm.py @@ -14,6 +14,7 @@ from loguru import logger from openai import NOT_GIVEN from pipecat.adapters.services.open_ai_adapter import OpenAILLMInvocationParams +from pipecat.adapters.services.open_ai_adapter import is_given as openai_is_given from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.sarvam._sdk import sdk_headers @@ -158,11 +159,11 @@ class SarvamLLMService(OpenAILLMService): tool_choice = params_from_context.get("tool_choice", NOT_GIVEN) has_tools = ( - tools is not NOT_GIVEN + openai_is_given(tools) and tools is not None and (not isinstance(tools, list) or len(tools) > 0) ) - has_tool_choice = tool_choice is not NOT_GIVEN and tool_choice is not None + has_tool_choice = openai_is_given(tool_choice) and tool_choice is not None if has_tool_choice and not has_tools: raise ValueError("Sarvam requires non-empty `tools` when `tool_choice` is provided.") diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 1506b84dc..fd40dbcee 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -59,7 +59,7 @@ from pipecat.frames.frames import ( TTSStoppedFrame, ) from pipecat.services.sarvam._sdk import sdk_headers -from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven +from pipecat.services.settings import NOT_GIVEN, TTSSettings, _NotGiven, is_given from pipecat.services.tts_service import InterruptibleTTSService, TextAggregationMode, TTSService from pipecat.transcriptions.language import Language, resolve_language from pipecat.utils.tracing.service_decorators import traced_tts @@ -501,7 +501,7 @@ class SarvamHttpTTSService(TTSService): sample_rate = self._config.default_sample_rate # Set default voice based on model if not specified via any mechanism - if voice_id is None and (settings is None or settings.voice is NOT_GIVEN): + if voice_id is None and (settings is None or not is_given(settings.voice)): default_settings.voice = self._config.default_speaker # Validate and clamp pace to model's valid range @@ -919,7 +919,7 @@ class SarvamTTSService(InterruptibleTTSService): sample_rate = self._config.default_sample_rate # Set default voice based on model if not specified via any mechanism - if voice_id is None and (settings is None or settings.voice is NOT_GIVEN): + if voice_id is None and (settings is None or not is_given(settings.voice)): default_settings.voice = self._config.default_speaker # Validate and clamp pace to model's valid range