TokenLimitTerminator

class TokenLimitTerminator(BaseTerminator):

Terminate agent if number of tokens reached to token limit threshold.

Parameters:

  • token_limit (int): Token limit threshold.

init

def __init__(self, token_limit: int):

_validate

def _validate(self):

is_terminated

def is_terminated(self, num_tokens: int):

Whether terminate the agent by checking number of used tokens reached to token limit.

Parameters:

  • num_tokens (int): Number of tokens.

Returns:

tuple: A tuple containing whether the agent should be terminated and a string of termination reason.

reset

def reset(self):

Reset the terminator.