| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | from collections.abc import Sequence |
| 5 | from typing import TYPE_CHECKING |
| 6 | |
| 7 | from vllm.entrypoints.generate.base.protocol import ( |
| 8 | DeltaMessage, |
| 9 | ExtractedToolCallInformation, |
| 10 | ) |
| 11 | from vllm.tool_parsers.abstract_tool_parser import Tool, ToolParser |
| 12 | |
| 13 | if TYPE_CHECKING: |
| 14 | from vllm.tokenizers import TokenizerLike |
| 15 | |
| 16 | |
| 17 | class GptOssToolParser(ToolParser): |
| 18 | """Stub tool parser for gpt-oss/harmony models. |
| 19 | |
| 20 | All output parsing is handled by HarmonyParser. This stub exists as a |
| 21 | capability declaration via HarmonyParser.tool_parser_cls. |
| 22 | """ |
| 23 | |
| 24 | structural_tag_model = "harmony" |
| 25 | |
| 26 | def __init__(self, tokenizer: "TokenizerLike", tools: list[Tool] | None = None): |
| 27 | super().__init__(tokenizer, tools) |
| 28 | |
| 29 | def extract_tool_calls( |
| 30 | self, model_output, request, **kwargs |
| 31 | ) -> ExtractedToolCallInformation: |
| 32 | raise NotImplementedError( |
| 33 | "GptOssToolParser is a stub. Use HarmonyParser for tool parsing." |
| 34 | ) |
| 35 | |
| 36 | def extract_tool_calls_streaming( |
| 37 | self, |
| 38 | previous_text: str, |
| 39 | current_text: str, |
| 40 | delta_text: str, |
| 41 | previous_token_ids: Sequence[int], |
| 42 | current_token_ids: Sequence[int], |
| 43 | delta_token_ids: Sequence[int], |
| 44 | request, |
| 45 | ) -> DeltaMessage | None: |
| 46 | raise NotImplementedError( |
| 47 | "GptOssToolParser is a stub. Use HarmonyParser for tool parsing." |
| 48 | ) |