fix(types): admit None on settings fields that accept it as a default
Service-specific Settings subclasses declared fields as T | _NotGiven (no None), but the services routinely pass None to those fields during init to mean "don't override — use the vendor's default". The field type just didn't reflect that a None value is valid, so pyright flagged every None at the call sites. Change the declarations to T | None | _NotGiven, matching the pattern already used by ServiceSettings.model and TTSSettings.language. No constructor-call changes; the default_factory stays NOT_GIVEN. Fields touched across 11 files: - services/settings.py: TTSSettings.voice (base class; covers asyncai, cartesia, elevenlabs, fish, hume, kokoro, lmnt, mistral, neuphonic, piper, resembleai, rime, xtts TTS services). - services/aws/llm.py: latency. - services/aws/tts.py: engine, pitch, rate, volume, lexicon_names. - services/azure/tts.py: emphasis, pitch, rate, role, style, style_degree, volume. - services/google/gemini_live/llm.py: vad. - services/google/llm.py: thinking. - services/google/stt.py: language_codes. - services/inworld/tts.py: speaking_rate, temperature. - services/openai/tts.py: instructions, speed. - services/speechmatics/stt.py: 13 fields (domain, operating_point, max_delay, end_of_utterance_*, punctuation_overrides, *_partials, split_sentences, enable_diarization, speaker_*, max_speakers, prefer_current_speaker, extra_params). - services/ultravox/llm.py: output_medium. Clears 94 pyright errors (1035 -> 941).
This commit is contained in:
@@ -67,7 +67,7 @@ class AWSBedrockLLMSettings(LLMSettings):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
stop_sequences: list[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
stop_sequences: list[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
latency: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
latency: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
enable_prompt_caching: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
enable_prompt_caching: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
additional_model_request_fields: dict[str, Any] | _NotGiven = field(
|
additional_model_request_fields: dict[str, Any] | _NotGiven = field(
|
||||||
default_factory=lambda: NOT_GIVEN
|
default_factory=lambda: NOT_GIVEN
|
||||||
|
|||||||
@@ -133,11 +133,11 @@ class AWSPollyTTSSettings(TTSSettings):
|
|||||||
lexicon_names: List of pronunciation lexicons to apply.
|
lexicon_names: List of pronunciation lexicons to apply.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
engine: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
engine: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
pitch: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
pitch: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
rate: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
rate: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
volume: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
volume: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
lexicon_names: list[str] | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
lexicon_names: list[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
|
||||||
|
|
||||||
class AWSPollyTTSService(TTSService):
|
class AWSPollyTTSService(TTSService):
|
||||||
|
|||||||
@@ -80,13 +80,13 @@ class AzureTTSSettings(TTSSettings):
|
|||||||
volume: Volume level (e.g., "+20%", "loud", "x-soft").
|
volume: Volume level (e.g., "+20%", "loud", "x-soft").
|
||||||
"""
|
"""
|
||||||
|
|
||||||
emphasis: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
emphasis: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
pitch: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
pitch: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
rate: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
rate: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
role: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
role: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
style: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
style: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
style_degree: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
style_degree: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
volume: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
volume: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
|
||||||
|
|
||||||
class AzureBaseTTSService:
|
class AzureBaseTTSService:
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ class GeminiLiveLLMSettings(LLMSettings):
|
|||||||
modalities: GeminiModalities | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
modalities: GeminiModalities | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
language: Language | str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
language: Language | str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
media_resolution: GeminiMediaResolution | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
media_resolution: GeminiMediaResolution | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
vad: GeminiVADParams | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
vad: GeminiVADParams | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
context_window_compression: ContextWindowCompressionParams | dict | _NotGiven = field(
|
context_window_compression: ContextWindowCompressionParams | dict | _NotGiven = field(
|
||||||
default_factory=lambda: NOT_GIVEN
|
default_factory=lambda: NOT_GIVEN
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class GoogleLLMSettings(LLMSettings):
|
|||||||
thinking: Thinking configuration.
|
thinking: Thinking configuration.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
thinking: Union["GoogleLLMService.ThinkingConfig", _NotGiven] = field(
|
thinking: Union["GoogleLLMService.ThinkingConfig", None, _NotGiven] = field(
|
||||||
default_factory=lambda: NOT_GIVEN
|
default_factory=lambda: NOT_GIVEN
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ class GoogleSTTSettings(STTSettings):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
languages: list[Language] | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
languages: list[Language] | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
language_codes: list[str] | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
language_codes: list[str] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
use_separate_recognition_per_channel: bool | _NotGiven = field(
|
use_separate_recognition_per_channel: bool | _NotGiven = field(
|
||||||
default_factory=lambda: NOT_GIVEN
|
default_factory=lambda: NOT_GIVEN
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ class InworldTTSSettings(TTSSettings):
|
|||||||
temperature: Temperature for speech synthesis.
|
temperature: Temperature for speech synthesis.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
speaking_rate: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
speaking_rate: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
temperature: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
temperature: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
|
||||||
_aliases: ClassVar[dict[str, str]] = {
|
_aliases: ClassVar[dict[str, str]] = {
|
||||||
"voiceId": "voice",
|
"voiceId": "voice",
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ class OpenAITTSSettings(TTSSettings):
|
|||||||
speed: Voice speed control (0.25 to 4.0, default 1.0).
|
speed: Voice speed control (0.25 to 4.0, default 1.0).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
instructions: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
instructions: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
speed: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
speed: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
|
||||||
|
|
||||||
class OpenAITTSService(TTSService):
|
class OpenAITTSService(TTSService):
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ class TTSSettings(ServiceSettings):
|
|||||||
``__init__`` methods do the same at construction time.
|
``__init__`` methods do the same at construction time.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
voice: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
voice: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
language: Language | str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
language: Language | str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
|
||||||
_aliases: ClassVar[dict[str, str]] = {"voice_id": "voice"}
|
_aliases: ClassVar[dict[str, str]] = {"voice_id": "voice"}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class SpeechmaticsSTTSettings(STTSettings):
|
|||||||
extra_params: Extra parameters for the STT engine.
|
extra_params: Extra parameters for the STT engine.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
domain: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
domain: str | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
turn_detection_mode: TurnDetectionMode | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
turn_detection_mode: TurnDetectionMode | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
speaker_active_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
speaker_active_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
speaker_passive_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
speaker_passive_format: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
@@ -125,18 +125,22 @@ class SpeechmaticsSTTSettings(STTSettings):
|
|||||||
additional_vocab: list[AdditionalVocabEntry] | _NotGiven = field(
|
additional_vocab: list[AdditionalVocabEntry] | _NotGiven = field(
|
||||||
default_factory=lambda: NOT_GIVEN
|
default_factory=lambda: NOT_GIVEN
|
||||||
)
|
)
|
||||||
operating_point: OperatingPoint | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
operating_point: OperatingPoint | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
max_delay: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
max_delay: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
end_of_utterance_silence_trigger: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
end_of_utterance_silence_trigger: float | None | _NotGiven = field(
|
||||||
end_of_utterance_max_delay: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
default_factory=lambda: NOT_GIVEN
|
||||||
punctuation_overrides: dict[str, Any] | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
)
|
||||||
include_partials: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
end_of_utterance_max_delay: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
split_sentences: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
punctuation_overrides: dict[str, Any] | None | _NotGiven = field(
|
||||||
enable_diarization: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
default_factory=lambda: NOT_GIVEN
|
||||||
speaker_sensitivity: float | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
)
|
||||||
max_speakers: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
include_partials: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
prefer_current_speaker: bool | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
split_sentences: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
extra_params: dict[str, Any] | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
enable_diarization: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
speaker_sensitivity: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
max_speakers: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
prefer_current_speaker: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
extra_params: dict[str, Any] | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN)
|
||||||
|
|
||||||
#: Fields that can be updated on a live connection via the Speechmatics
|
#: Fields that can be updated on a live connection via the Speechmatics
|
||||||
#: diarization-config API — no reconnect needed.
|
#: diarization-config API — no reconnect needed.
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class UltravoxRealtimeLLMSettings(LLMSettings):
|
|||||||
output_medium: The output medium for the model ("voice" or "text").
|
output_medium: The output medium for the model ("voice" or "text").
|
||||||
"""
|
"""
|
||||||
|
|
||||||
output_medium: str | _NotGiven = field(default=NOT_GIVEN)
|
output_medium: str | None | _NotGiven = field(default=NOT_GIVEN)
|
||||||
|
|
||||||
|
|
||||||
class AgentInputParams(BaseModel):
|
class AgentInputParams(BaseModel):
|
||||||
|
|||||||
Reference in New Issue
Block a user