Gate NIM thinking params behind NIM_ENABLE_THINKING env var

Mistral models reject chat_template_kwargs, causing 400 errors. Make
thinking params (chat_template_kwargs, reasoning_budget) opt-in via
NIM_ENABLE_THINKING env var (default false) so only models that need it
(kimi, nemotron) receive them.
This commit is contained in:
Alishahryar1 2026-03-27 21:44:36 -07:00
parent ab0d6aca14
commit b75f47b62d
6 changed files with 49 additions and 8 deletions

View file

@ -90,6 +90,9 @@ class Settings(BaseSettings):
# ==================== NIM Settings ====================
nim: NimSettings = Field(default_factory=NimSettings)
nim_enable_thinking: bool = Field(
default=False, validation_alias="NIM_ENABLE_THINKING"
)
# ==================== Voice Note Transcription ====================
voice_note_enabled: bool = Field(
@ -171,6 +174,13 @@ class Settings(BaseSettings):
)
return v
@model_validator(mode="after")
def _inject_nim_thinking(self) -> Settings:
self.nim = self.nim.model_copy(
update={"enable_thinking": self.nim_enable_thinking}
)
return self
@model_validator(mode="after")
def check_nvidia_nim_api_key(self) -> Settings:
if (