Narrow settings.model at service boundaries, not via truthiness
Two services were reading `_settings.model` (typed `str | _NotGiven | None` because NOT_GIVEN is the default) and coercing it with `or ""` or similar. `_NotGiven.__bool__` returns False, so the runtime behavior happened to work, but the type was a lie — pyright saw `str | _NotGiven` flowing into APIs that required `str` or `str | None`. - `AIService._sync_model_name_to_metrics`: use `isinstance(model, str)` narrowing with an empty-string fallback. Equivalent runtime behavior, honest type, no truthiness dependency on a sentinel. - `SarvamLLMService.__init__`: validate the model is a real string before handing it to `_validate_model(str)`. A non-string model at this point is a configuration bug; raise `ValueError` so the error is clear and survives `python -O` (unlike an assert).
This commit is contained in:
@@ -2,14 +2,8 @@
|
||||
"typeCheckingMode": "basic",
|
||||
"pythonVersion": "3.11",
|
||||
"pythonPlatform": "All",
|
||||
"include": [
|
||||
"scripts",
|
||||
"src/pipecat"
|
||||
],
|
||||
"exclude": [
|
||||
"**/*_pb2.py",
|
||||
"**/__pycache__"
|
||||
],
|
||||
"include": ["scripts", "src/pipecat"],
|
||||
"exclude": ["**/*_pb2.py", "**/__pycache__"],
|
||||
"ignore": [
|
||||
"tests",
|
||||
"src/pipecat/adapters/base_llm_adapter.py",
|
||||
@@ -40,7 +34,6 @@
|
||||
"src/pipecat/processors/frameworks/rtvi/processor.py",
|
||||
"src/pipecat/processors/frameworks/strands_agents.py",
|
||||
"src/pipecat/processors/gstreamer/pipeline_source.py",
|
||||
"src/pipecat/services/ai_service.py",
|
||||
"src/pipecat/services/anthropic/llm.py",
|
||||
"src/pipecat/services/assemblyai/stt.py",
|
||||
"src/pipecat/services/asyncai/tts.py",
|
||||
@@ -106,7 +99,6 @@
|
||||
"src/pipecat/services/resembleai/tts.py",
|
||||
"src/pipecat/services/rime/tts.py",
|
||||
"src/pipecat/services/sambanova/llm.py",
|
||||
"src/pipecat/services/sarvam/llm.py",
|
||||
"src/pipecat/services/sarvam/stt.py",
|
||||
"src/pipecat/services/sarvam/tts.py",
|
||||
"src/pipecat/services/simli/video.py",
|
||||
@@ -138,4 +130,4 @@
|
||||
"src/pipecat/transports/whatsapp/client.py"
|
||||
],
|
||||
"reportMissingImports": false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user