From 87337a1550fc307eb168fa9f6c8328eae177fcf8 Mon Sep 17 00:00:00 2001 From: Leonid Kuligin Date: Fri, 8 Mar 2024 12:51:27 +0100 Subject: [PATCH] fix temperature=0 (#53) --- libs/vertexai/langchain_google_vertexai/llms.py | 2 +- libs/vertexai/tests/unit_tests/test_llm.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/vertexai/langchain_google_vertexai/llms.py b/libs/vertexai/langchain_google_vertexai/llms.py index ca16de4a..7221c96b 100644 --- a/libs/vertexai/langchain_google_vertexai/llms.py +++ b/libs/vertexai/langchain_google_vertexai/llms.py @@ -215,7 +215,7 @@ def _default_params(self) -> Dict[str, Any]: updated_params = {} for param_name, param_value in params.items(): default_value = default_params.get(param_name) - if param_value or default_value: + if param_value is not None or default_value is not None: updated_params[param_name] = ( param_value if param_value is not None else default_value ) diff --git a/libs/vertexai/tests/unit_tests/test_llm.py b/libs/vertexai/tests/unit_tests/test_llm.py index 8d65221e..5fc23d7e 100644 --- a/libs/vertexai/tests/unit_tests/test_llm.py +++ b/libs/vertexai/tests/unit_tests/test_llm.py @@ -47,3 +47,9 @@ def test_vertexai_args_passed() -> None: }, }, ) + assert ( + model_instance.generate_content.call_args.kwargs["generation_config"][ + "temperature" + ] + == 0 + )