diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7534ae55907..4d8e60d3929 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,8 @@ repos: entry: tools/mypy.sh 0 "local" language: python types: [python] - additional_dependencies: &mypy_deps [mypy==1.11.1, types-cachetools, types-setuptools, types-PyYAML, types-requests, pydantic] + additional_dependencies: &mypy_deps [mypy==1.16.0, types-cachetools, + types-setuptools, types-PyYAML, types-requests, pydantic] stages: [pre-commit] # Don't run in CI - id: mypy-3.9 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward name: Run mypy for Python 3.9 diff --git a/vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py b/vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py index c7030d34d45..a225180e055 100644 --- a/vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py +++ b/vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py @@ -237,7 +237,6 @@ def extract_tool_calls_streaming( return delta try: - current_tool_call = partial_json_parser.loads( tool_call_portion or "{}", flags) if tool_call_portion else None @@ -252,7 +251,7 @@ def extract_tool_calls_streaming( # case - we haven't sent the tool name yet. If it's available, send # it. otherwise, wait until it's available. if not self.current_tool_name_sent: - if (current_tool_call is None): + if current_tool_call is None: return None function_name: Union[str, None] = current_tool_call.get("name") if function_name: @@ -292,6 +291,8 @@ def extract_tool_calls_streaming( # JSON to the current partially-parsed JSON prev_arguments = ( self.prev_tool_call_arr[self.current_tool_id].get("arguments")) + if current_tool_call is None: + return None cur_arguments = current_tool_call.get("arguments") logger.debug("diffing old arguments: %s", prev_arguments) @@ -359,9 +360,13 @@ def extract_tool_calls_streaming( # handle saving the state for the current tool into # the "prev" list for use in diffing for the next iteration if self.current_tool_id == len(self.prev_tool_call_arr) - 1: + if current_tool_call is None: + return None self.prev_tool_call_arr[self.current_tool_id] = \ current_tool_call else: + if current_tool_call is None: + return None self.prev_tool_call_arr.append(current_tool_call) return delta diff --git a/vllm/sampling_params.py b/vllm/sampling_params.py index a9a862384d1..929b5cf5d52 100644 --- a/vllm/sampling_params.py +++ b/vllm/sampling_params.py @@ -489,7 +489,8 @@ def update_from_generation_config( if eos_ids: self._all_stop_token_ids.update(eos_ids) if not self.ignore_eos: - eos_ids.update(self.stop_token_ids) + if self.stop_token_ids is not None: + eos_ids.update(self.stop_token_ids) self.stop_token_ids = list(eos_ids) def update_from_tokenizer(self, tokenizer: AnyTokenizer) -> None: