[Frontend] Support count_reasoning_tokens in the Streaming Parser Engine (#45802)
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
5cecfc0137
commit
ac2ae8798c
@@ -367,6 +367,10 @@ class Parser:
|
||||
tool call extraction via internal stream state.
|
||||
"""
|
||||
|
||||
def count_reasoning_tokens(self, token_ids: Sequence[int]) -> int:
|
||||
"""Return the number of reasoning tokens in generated token IDs."""
|
||||
return 0
|
||||
|
||||
|
||||
class DelegatingParser(Parser):
|
||||
"""
|
||||
@@ -939,6 +943,12 @@ class DelegatingParser(Parser):
|
||||
|
||||
return delta_message
|
||||
|
||||
def count_reasoning_tokens(self, token_ids: Sequence[int]) -> int:
|
||||
"""Count reasoning tokens through the configured reasoning parser."""
|
||||
if self._reasoning_parser is None:
|
||||
return 0
|
||||
return self._reasoning_parser.count_reasoning_tokens(token_ids)
|
||||
|
||||
def _flush_engine_parsers(
|
||||
self, delta_message: DeltaMessage | None
|
||||
) -> DeltaMessage | None:
|
||||
|
||||
Reference in New Issue
Block a user