vllm.tool_parsers.streaming
¶
Classes:
-
RequiredToolCallScanner–Incremental scanner owning the text of one required-tool-call stream.
Functions:
-
extract_named_tool_call_streaming–Build a streaming tool-call delta for forced named tool choice.
-
extract_required_tool_call_streaming–Stream required tool calls from new text using a per-stream scanner.
RequiredToolCallScanner
dataclass
¶
Incremental scanner owning the text of one required-tool-call stream.
Methods:
-
scan–Append and scan new text, retaining lexical state across deltas.
Source code in vllm/tool_parsers/streaming.py
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
scan(delta_text)
¶
Append and scan new text, retaining lexical state across deltas.
Source code in vllm/tool_parsers/streaming.py
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
_RequiredToolCallSpan
dataclass
¶
Where one element of a tool_choice="required" array sits in the text.
The model output for tool_choice="required" is a JSON array of
{"name": ..., "parameters": ...} objects. name is only set once
its string value is closed and decodes as JSON; name_end is the
offset just past that closing quote. args_start/args_end are the
character offsets of the parameters value (args_end is None
while the value is still being generated).
All offsets are prefix-stable: scanning any prefix of the text yields the same spans truncated to that prefix. That is what lets one scan of the current text tell what an earlier, shorter text had already revealed.
Methods:
-
ready_at–Whether the first
lengthcharacters of the text already made
Source code in vllm/tool_parsers/streaming.py
ready_at(length)
¶
Whether the first length characters of the text already made
this call streamable: its name was complete and its parameters value
had started.
Source code in vllm/tool_parsers/streaming.py
extract_named_tool_call_streaming(*, delta_text, function_name, function_name_returned, tool_call_idx, tool_call_id_type, tokenizer, tool_call_array_index=0)
¶
Build a streaming tool-call delta for forced named tool choice.
Source code in vllm/tool_parsers/streaming.py
extract_required_tool_call_streaming(*, delta_text, scanner, tool_call_idx, tool_call_id_type)
¶
Stream required tool calls from new text using a per-stream scanner.
The first chunk of each call carries its id, name and available arguments; subsequent chunks carry only new argument text. A delta may start several calls. The scanner owns accumulated text and lexical state.