From 1916b688facb2e1fa39988b6a3aa9b10220b0976 Mon Sep 17 00:00:00 2001 From: Leonid Kuligin Date: Thu, 11 Apr 2024 16:04:30 +0200 Subject: [PATCH] fix linter --- libs/vertexai/langchain_google_vertexai/chat_models.py | 4 ++-- libs/vertexai/tests/unit_tests/test_chat_models.py | 1 - libs/vertexai/tests/unit_tests/test_function_utils.py | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/vertexai/langchain_google_vertexai/chat_models.py b/libs/vertexai/langchain_google_vertexai/chat_models.py index 6e6ad0051..5a601261d 100644 --- a/libs/vertexai/langchain_google_vertexai/chat_models.py +++ b/libs/vertexai/langchain_google_vertexai/chat_models.py @@ -667,7 +667,7 @@ def _stream( self._is_gemini_model, usage_metadata=response.to_dict().get("usage_metadata"), ) - if run_manager: + if run_manager and isinstance(message.content, str): run_manager.on_llm_new_token(message.content) if isinstance(message, AIMessageChunk): yield ChatGenerationChunk( @@ -744,7 +744,7 @@ async def _astream( self._is_gemini_model, usage_metadata=chunk.to_dict().get("usage_metadata"), ) - if run_manager: + if run_manager and isinstance(message.content, str): await run_manager.on_llm_new_token(message.content) if isinstance(message, AIMessageChunk): yield ChatGenerationChunk( diff --git a/libs/vertexai/tests/unit_tests/test_chat_models.py b/libs/vertexai/tests/unit_tests/test_chat_models.py index 5f6f04efd..1f848c1b6 100644 --- a/libs/vertexai/tests/unit_tests/test_chat_models.py +++ b/libs/vertexai/tests/unit_tests/test_chat_models.py @@ -330,7 +330,6 @@ def test_default_params_gemini() -> None: assert mock_generate_content.call_args.args[0][0].parts[0].text == user_prompt - @pytest.mark.parametrize( "raw_candidate, expected", [ diff --git a/libs/vertexai/tests/unit_tests/test_function_utils.py b/libs/vertexai/tests/unit_tests/test_function_utils.py index f79336a1c..6c279ea0a 100644 --- a/libs/vertexai/tests/unit_tests/test_function_utils.py +++ b/libs/vertexai/tests/unit_tests/test_function_utils.py @@ -69,7 +69,6 @@ def test_format_tool_config(): assert isinstance(tool_config, ToolConfig) - def test_get_parameters_from_schema(): class StringEnum(str, Enum): pear = "pear"