Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tee_gateway/llm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,22 @@ def get_chat_model_cached(
response_modalities=[Modality.TEXT, Modality.IMAGE],
)

return ChatGoogleGenerativeAI(
# Unlike the other langchain-<provider> packages, langchain-google-genai
# types `temperature` as a plain float (default 0.7) and rejects None at
# construction. Build without it, then clear it: the field is not
# re-validated on assignment, and a None temperature is dropped from the
# outgoing GenerationConfig, so the request carries no temperature.
google_llm = ChatGoogleGenerativeAI(
model=api_name,
google_api_key=config.google_api_key,
temperature=effective_temp,
**({} if effective_temp is None else {"temperature": effective_temp}),
max_output_tokens=max_tokens,
thinking_budget=cfg.thinking_budget,
include_thoughts=False if cfg.thinking_budget is not None else None,
)
if effective_temp is None:
google_llm.temperature = None # type: ignore[assignment]
return google_llm

elif provider == "openai":
if not config.openai_api_key:
Expand Down
8 changes: 8 additions & 0 deletions tee_gateway/test/test_tee_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,14 @@ def test_opus_omits_temperature(self):
model = get_chat_model_cached("claude-opus-5", 0.0, 1024)
self.assertIsNone(model.temperature)

def test_gemini_4_argon_omits_temperature(self):
"""langchain-google-genai rejects temperature=None at construction, so
the Google path has to clear it afterwards — and it must then be absent
from the generation config actually sent."""
model = get_chat_model_cached("gemini-4-argon", 0.0, 1024)
self.assertIsNone(model.temperature)
self.assertIsNone(model._prepare_params(stop=None).temperature)

def test_temperature_supporting_model_keeps_it(self):
model = get_chat_model_cached("gpt-4.1", 0.0, 1024)
self.assertEqual(model.temperature, 0.0)
Expand Down
Loading