vllm.entrypoints.openai.tool_parsers.abstract_tool_parser
ToolParser
¶
Abstract ToolParser class that should not be used directly. Provided properties and methods should be used in derived classes.
Source code in vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
__init__
¶
__init__(tokenizer: AnyTokenizer)
Source code in vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
adjust_request
¶
adjust_request(
request: ChatCompletionRequest,
) -> ChatCompletionRequest
Static method that used to adjust the request parameters.
extract_tool_calls
¶
extract_tool_calls(
model_output: str, request: ChatCompletionRequest
) -> ExtractedToolCallInformation
Static method that should be implemented for extracting tool calls from a complete model-generated string. Used for non-streaming responses where we have the entire model response available before sending to the client. Static because it's stateless.
Source code in vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
extract_tool_calls_streaming
¶
extract_tool_calls_streaming(
previous_text: str,
current_text: str,
delta_text: str,
previous_token_ids: Sequence[int],
current_token_ids: Sequence[int],
delta_token_ids: Sequence[int],
request: ChatCompletionRequest,
) -> Union[DeltaMessage, None]
Instance method that should be implemented for extracting tool calls from an incomplete response; for use when handling tool calls and streaming. Has to be an instance method because it requires state - the current tokens/diffs, but also the information about what has previously been parsed and extracted (see constructor)
Source code in vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
ToolParserManager
¶
Source code in vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
_register_module
classmethod
¶
_register_module(
module: type,
module_name: Optional[Union[str, list[str]]] = None,
force: bool = True,
) -> None
Source code in vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
get_tool_parser
classmethod
¶
get_tool_parser(name) -> type
Get tool parser by name which is registered by register_module
.
Raise a KeyError exception if the name is not registered.
Source code in vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
import_tool_parser
classmethod
¶
import_tool_parser(plugin_path: str) -> None
Import a user-defined tool parser by the path of the tool parser define file.
Source code in vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
register_module
classmethod
¶
register_module(
name: Optional[Union[str, list[str]]] = None,
force: bool = True,
module: Union[type, None] = None,
) -> Union[type, Callable]
Register module with the given name or name list. it can be used as a decoder(with module as None) or normal function(with module as not None).