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

Method from_token

examples/server/server.py:3730–3747  ·  view source on GitHub ↗
(
        cls,
        *,
        model: Model,
        prev_tokens: Sequence[int],
        prev_text_bytes: Optional[Union[bytes, bytearray]] = None,
        token: int,
    )

Source from the content-addressed store, hash-verified

3728
3729 @classmethod
3730 def from_token(
3731 cls,
3732 *,
3733 model: Model,
3734 prev_tokens: Sequence[int],
3735 prev_text_bytes: Optional[Union[bytes, bytearray]] = None,
3736 token: int,
3737 ) -> "Token":
3738 return cls(
3739 token=token,
3740 text_bytes=(
3741 model.token_bytes_with_prev_bytes(prev_tokens, prev_text_bytes, token)
3742 if prev_text_bytes is not None
3743 else model.token_bytes_with_prev(prev_tokens, token)
3744 ),
3745 token_logprob=None,
3746 top_logprobs=None,
3747 )
3748
3749 @classmethod
3750 def from_logits(

Callers 3

sample_completionMethod · 0.80

Calls 2

token_bytes_with_prevMethod · 0.80

Tested by

no test coverage detected