Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: xiyuan lee <[email protected]>
  • Loading branch information
xiyuan-lee committed Nov 19, 2024
1 parent ef7173d commit fec6efb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fec6efb

Please sign in to comment.