[Misc] add return token strs for tokenize (#18941)

Signed-off-by: reidliu41 <reid201711@gmail.com>
Co-authored-by: reidliu41 <reid201711@gmail.com>
This commit is contained in:
Reid
2025-06-01 02:00:11 +08:00
committed by GitHub
parent 9a1b9b99d7
commit 20079c6e36
3 changed files with 66 additions and 15 deletions

View File

@@ -1563,6 +1563,11 @@ class TokenizeCompletionRequest(OpenAIBaseModel):
"If true (the default), special tokens (e.g. BOS) will be added to "
"the prompt."),
)
return_token_strs: Optional[bool] = Field(
default=False,
description=("If true, also return the token strings "
"corresponding to the token ids."),
)
class TokenizeChatRequest(OpenAIBaseModel):
@@ -1576,6 +1581,11 @@ class TokenizeChatRequest(OpenAIBaseModel):
"This is a parameter used by chat template in tokenizer config of the "
"model."),
)
return_token_strs: Optional[bool] = Field(
default=False,
description=("If true, also return the token strings "
"corresponding to the token ids."),
)
continue_final_message: bool = Field(
default=False,
description=
@@ -1633,6 +1643,7 @@ class TokenizeResponse(OpenAIBaseModel):
count: int
max_model_len: int
tokens: list[int]
token_strs: Optional[list[str]] = None
class DetokenizeRequest(OpenAIBaseModel):