| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | """Semantic event types emitted by the streaming parser engine.""" |
| 4 | |
| 5 | from __future__ import annotations |
| 6 | |
| 7 | from dataclasses import dataclass |
| 8 | from enum import Enum, auto |
| 9 | |
| 10 | |
| 11 | class EventType(Enum): |
| 12 | TEXT_CHUNK = auto() |
| 13 | REASONING_START = auto() |
| 14 | REASONING_CHUNK = auto() |
| 15 | REASONING_END = auto() |
| 16 | TOOL_CALL_START = auto() |
| 17 | TOOL_NAME = auto() |
| 18 | ARG_VALUE_CHUNK = auto() |
| 19 | TOOL_CALL_END = auto() |
| 20 | |
| 21 | |
| 22 | @dataclass(slots=True) |
| 23 | class SemanticEvent: |
| 24 | type: EventType |
| 25 | value: str = "" |
| 26 | tool_index: int = -1 |
| 27 | token_count: int = 0 |