Skip to main content

StubTokenCounter

count_tokens_from_messages

Token counting for STUB models, directly returning a constant. Parameters:
  • messages (List[OpenAIMessage]): Message list with the chat history in OpenAI API format.
Returns: int: A constant to act as the number of the tokens in the messages.

encode

Encode text into token IDs for STUB models. Parameters:
  • text (str): The text to encode.
Returns: List[int]: List of token IDs.

decode

Decode token IDs back to text for STUB models. Parameters:
  • token_ids (List[int]): List of token IDs to decode.
Returns: str: Decoded text.

StubModel

A dummy model used for unit tests.

init

All arguments are unused for the dummy model.

token_counter

Returns: BaseTokenCounter: The token counter following the model’s tokenization style.

_run

Returns: Dict[str, Any]: Response in the OpenAI API format.