Documentation Index
Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
Use this file to discover all available pages before exploring further.
StubTokenCounter
class StubTokenCounter(BaseTokenCounter):
count_tokens_from_messages
def count_tokens_from_messages(self, messages: List[OpenAIMessage]):
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
def encode(self, text: str):
Encode text into token IDs for STUB models.
Parameters:
- text (str): The text to encode.
Returns:
List[int]: List of token IDs.
decode
def decode(self, token_ids: List[int]):
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
class StubModel(BaseModelBackend):
A dummy model used for unit tests.
init
def __init__(
self,
model_type: Union[ModelType, str],
model_config_dict: Optional[Dict[str, Any]] = None,
api_key: Optional[str] = None,
url: Optional[str] = None,
token_counter: Optional[BaseTokenCounter] = None,
timeout: Optional[float] = None,
max_retries: int = 3
):
All arguments are unused for the dummy model.
token_counter
Returns:
BaseTokenCounter: The token counter following the model’s
tokenization style.
_run
def _run(
self,
messages: List[OpenAIMessage],
response_format: Optional[Type[BaseModel]] = None,
tools: Optional[List[Dict[str, Any]]] = None
):
Returns:
Dict[str, Any]: Response in the OpenAI API format.