diff --git a/libs/genai/langchain_google_genai/_common.py b/libs/genai/langchain_google_genai/_common.py index 3bffd24d9..ba1ba0944 100644 --- a/libs/genai/langchain_google_genai/_common.py +++ b/libs/genai/langchain_google_genai/_common.py @@ -210,6 +210,15 @@ class _BaseGoogleGenerativeAI(BaseModel): ``` """ # noqa: E501 + seed: int | None = Field( + default=None, + ) + """ + Seed used in decoding. + + If not set, the request uses a randomly generated seed. + """ + @property def lc_secrets(self) -> dict[str, str]: # Either could contain the API key diff --git a/libs/genai/langchain_google_genai/chat_models.py b/libs/genai/langchain_google_genai/chat_models.py index 27b5032ce..48b4ca35f 100644 --- a/libs/genai/langchain_google_genai/chat_models.py +++ b/libs/genai/langchain_google_genai/chat_models.py @@ -2032,6 +2032,7 @@ def _prepare_params( or self.include_thoughts is not None else None ), + "seed": self.seed, }.items() if v is not None } diff --git a/libs/genai/langchain_google_genai/llms.py b/libs/genai/langchain_google_genai/llms.py index 8647ef266..26e42bbdc 100644 --- a/libs/genai/langchain_google_genai/llms.py +++ b/libs/genai/langchain_google_genai/llms.py @@ -83,6 +83,7 @@ def validate_environment(self) -> Self: transport=self.transport, additional_headers=self.additional_headers, safety_settings=self.safety_settings, + seed=self.seed, ) return self