From 9e97e35005f4c48e3139830d21fc834853e3af50 Mon Sep 17 00:00:00 2001 From: COSMOPlat Date: Tue, 19 Nov 2024 16:20:35 +0800 Subject: [PATCH] Fix linter errors --- .../openai/tool_parsers/hermes_tool_parser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py b/vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py index 2fb134c9d056f..fbd6801644f3b 100644 --- a/vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py +++ b/vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py @@ -187,9 +187,12 @@ def extract_tool_calls_streaming( and cur_tool_end_count > prev_tool_end_count): diff = self.prev_tool_call_arr[self.current_tool_id].get( "arguments") - if diff: - diff = diff.encode('utf-8').decode('unicode_escape') if diff is str else diff - diff = json.dumps(diff, ensure_ascii=False)[len(self.streamed_args_for_tool[self.current_tool_id]):] + if diff: + diff = diff.encode('utf-8').decode( + 'unicode_escape') if diff is str else diff + diff = json.dumps( + diff, ensure_ascii=False + )[len(self.streamed_args_for_tool[self.current_tool_id]):] logger.debug( "Finishing tool and found diff that had not " "been streamed yet: %s", diff) @@ -305,7 +308,8 @@ def extract_tool_calls_streaming( # last case -- we have an update to existing arguments. elif cur_arguments and prev_arguments: - if isinstance(delta_text, str) and len(delta_text.rstrip())>=1 and delta_text.rstrip()[-1] == '}': + if isinstance(delta_text, str) and len(delta_text.rstrip( + )) >= 1 and delta_text.rstrip()[-1] == '}': delta_text = delta_text.rstrip()[:-1] logger.debug("got diff %s", delta_text)