fix: omit None config values from Gemini GenerateContentConfig (#5528)

This commit is contained in:
Hrushikesh Yadav
2026-06-16 11:54:42 +05:30
committed by GitHub
parent bb69b036b5
commit 30d172e826
2 changed files with 51 additions and 6 deletions
+9 -6
View File
@@ -157,12 +157,15 @@ class GeminiLLM(LLMBase):
# Extract system instruction and reformat messages
system_instruction, contents = self._reformat_messages(messages)
# Prepare generation config
config_params = {
"temperature": self.config.temperature,
"max_output_tokens": self.config.max_tokens,
"top_p": self.config.top_p,
}
# Prepare generation config — only include non-None values so the
# Gemini SDK uses its own defaults instead of rejecting None.
config_params = {}
if self.config.temperature is not None:
config_params["temperature"] = self.config.temperature
if self.config.max_tokens is not None:
config_params["max_output_tokens"] = self.config.max_tokens
if self.config.top_p is not None:
config_params["top_p"] = self.config.top_p
# Add system instruction to config if present
if system_instruction: