[API] Add token offsets to render endpoints (/v1/.../render) (#44226)

Signed-off-by: HyunKyun Moon <mhg5303@gmail.com>
This commit is contained in:
Hyunkyun Moon
2026-06-26 05:02:52 -07:00
committed by GitHub
parent d980a3cc6e
commit 950ee4c2e4
13 changed files with 518 additions and 22 deletions
+4
View File
@@ -38,6 +38,10 @@ class TokensInput(_InputOptions):
prompt: NotRequired[str]
"""The prompt text corresponding to the token IDs, if available."""
prompt_token_offsets: NotRequired[list[tuple[int, int]] | None]
"""Char-level (start, end) offsets per token, propagated from the
renderer's TokensPrompt when offsets were computed."""
def tokens_input(
prompt_token_ids: list[int],
+6
View File
@@ -115,6 +115,12 @@ class TokensPrompt(_PromptOptions):
token_type_ids: NotRequired[list[int]]
"""A list of token type IDs to pass to the cross encoder model."""
prompt_token_offsets: NotRequired[list[tuple[int, int]] | None]
"""Char-level (start, end) offsets per token, relative to the
tokenized source string. Present only when offsets were requested
AND a Fast (Rust-backed) tokenizer was used AND no multimodal data
was present. The list length equals the length of `prompt_token_ids`."""
class EmbedsPrompt(_PromptOptions):
"""Schema for a prompt provided via token embeddings."""