From d6827322b76818fa0840fde04901d3305c40db15 Mon Sep 17 00:00:00 2001 From: Hsin Chen Date: Wed, 15 May 2024 17:33:19 -0700 Subject: [PATCH] Formatting fix --- morpheus/llm/nodes/langchain_agent_node.py | 11 ++++++----- tests/llm/nodes/test_langchain_agent_node.py | 7 +++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/morpheus/llm/nodes/langchain_agent_node.py b/morpheus/llm/nodes/langchain_agent_node.py index 131a8814ed..34b62bc2b4 100644 --- a/morpheus/llm/nodes/langchain_agent_node.py +++ b/morpheus/llm/nodes/langchain_agent_node.py @@ -37,7 +37,10 @@ class LangChainAgentNode(LLMNodeBase): The agent executor to use to execute. """ - def __init__(self, agent_executor: "AgentExecutor", replace_exceptions: bool=False, replace_exceptions_value: typing.Optional[str]=None): + def __init__(self, + agent_executor: "AgentExecutor", + replace_exceptions: bool = False, + replace_exceptions_value: typing.Optional[str] = None): super().__init__() self._agent_executor = agent_executor @@ -94,10 +97,8 @@ async def execute(self, context: LLMContext) -> LLMContext: # pylint: disable=i # If the agent encounters a parsing error or a server error after retries, replace the error # with a default value to prevent the pipeline from crashing results[i][j] = self._replace_exceptions_value - logger.warning( - f"Exception encountered in result[{i}][{j}]: {answer}. " - f"Replacing with default message: \"{self._replace_exceptions_value}\"." - ) + logger.warning(f"Exception encountered in result[{i}][{j}]: {answer}. " + f"Replacing with default message: \"{self._replace_exceptions_value}\".") context.set_output(results) diff --git a/tests/llm/nodes/test_langchain_agent_node.py b/tests/llm/nodes/test_langchain_agent_node.py index f3104f38c0..6a9ddc4a4a 100644 --- a/tests/llm/nodes/test_langchain_agent_node.py +++ b/tests/llm/nodes/test_langchain_agent_node.py @@ -145,6 +145,7 @@ def test_execute_error(mock_chat_completion: tuple[mock.MagicMock, mock.MagicMoc node = LangChainAgentNode(agent_executor=agent) assert isinstance(execute_node(node, input="input1"), RuntimeError) + @pytest.mark.parametrize( "arun_return,expected_output", [ @@ -164,9 +165,7 @@ def test_execute_replaces_exceptions( arun_return: list, expected_output: list, ): - placeholder_input_values = { - "foo": "bar" - } # a non-empty placeholder input for the context + placeholder_input_values = {"foo": "bar"} # a non-empty placeholder input for the context mock_agent_executor.arun.return_value = arun_return node = LangChainAgentNode( @@ -175,4 +174,4 @@ def test_execute_replaces_exceptions( replace_exceptions_value="Default error message.", ) output = execute_node(node, **placeholder_input_values) - assert output == expected_output \ No newline at end of file + assert output == expected_output