MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / token_bytes_with_prev_bytes

Method token_bytes_with_prev_bytes

examples/server/server.py:12070–12077  ·  view source on GitHub ↗
(
        self,
        prev_tokens: Sequence[int],
        prev_text_bytes: Union[bytes, bytearray],
        token: int,
    )

Source from the content-addressed store, hash-verified

12068 return current[len(previous) :]
12069
12070 def token_bytes_with_prev_bytes(
12071 self,
12072 prev_tokens: Sequence[int],
12073 prev_text_bytes: Union[bytes, bytearray],
12074 token: int,
12075 ) -> bytes:
12076 current = self.detokenize([*prev_tokens, token])
12077 return current[len(prev_text_bytes) :]
12078
12079 def clear_batch(self) -> None:
12080 self.batch.n_tokens = 0

Callers 2

from_tokenMethod · 0.80
from_logitsMethod · 0.80

Calls 1

detokenizeMethod · 0.95

Tested by

no test coverage detected