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).
6.0 KiB
6.0 KiB