camel.terminators package#

Submodules#

camel.terminators.base module#

class camel.terminators.base.BaseTerminator(*args, **kwargs)[source]#

Bases: ABC

abstract is_terminated(*args, **kwargs) Tuple[bool, str | None][source]#
abstract reset()[source]#
class camel.terminators.base.ResponseTerminator(*args, **kwargs)[source]#

Bases: BaseTerminator

abstract is_terminated(messages: List[BaseMessage]) Tuple[bool, str | None][source]#
abstract reset()[source]#

camel.terminators.response_terminator module#

class camel.terminators.response_terminator.ResponseWordsTerminator(words_dict: Dict[str, int], case_sensitive: bool = False, mode: TerminationMode = TerminationMode.ANY)[source]#

Bases: ResponseTerminator

Terminate agent when some words reached to occurrence limit by any message of the response.

Parameters:
  • words_dict (dict) – Dictionary of words and its occurrence threshold.

  • case_sensitive (bool) – Whether count the words as case-sensitive. (default: False)

  • mode (TerminationMode) – Whether terminate agent if any or all pre-set words reached the threshold. (default: TerminationMode.ANY)

is_terminated(messages: List[BaseMessage]) Tuple[bool, str | None][source]#

Whether terminate the agent by checking the occurrence of specified words reached to preset thresholds.

Parameters:

messages (list) – List of BaseMessage from a response.

Returns:

A tuple containing whether the agent should be

terminated and a string of termination reason.

Return type:

tuple

reset()[source]#

camel.terminators.token_limit_terminator module#

class camel.terminators.token_limit_terminator.TokenLimitTerminator(token_limit: int)[source]#

Bases: BaseTerminator

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

Parameters:

token_limit (int) – Token limit threshold.

is_terminated(num_tokens: int) Tuple[bool, str | None][source]#

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

Parameters:

num_tokens (int) – Number of tokens.

Returns:

A tuple containing whether the agent should be

terminated and a string of termination reason.

Return type:

tuple

reset()[source]#

Module contents#

class camel.terminators.BaseTerminator(*args, **kwargs)[source]#

Bases: ABC

abstract is_terminated(*args, **kwargs) Tuple[bool, str | None][source]#
abstract reset()[source]#
class camel.terminators.ResponseTerminator(*args, **kwargs)[source]#

Bases: BaseTerminator

abstract is_terminated(messages: List[BaseMessage]) Tuple[bool, str | None][source]#
abstract reset()[source]#
class camel.terminators.ResponseWordsTerminator(words_dict: Dict[str, int], case_sensitive: bool = False, mode: TerminationMode = TerminationMode.ANY)[source]#

Bases: ResponseTerminator

Terminate agent when some words reached to occurrence limit by any message of the response.

Parameters:
  • words_dict (dict) – Dictionary of words and its occurrence threshold.

  • case_sensitive (bool) – Whether count the words as case-sensitive. (default: False)

  • mode (TerminationMode) – Whether terminate agent if any or all pre-set words reached the threshold. (default: TerminationMode.ANY)

is_terminated(messages: List[BaseMessage]) Tuple[bool, str | None][source]#

Whether terminate the agent by checking the occurrence of specified words reached to preset thresholds.

Parameters:

messages (list) – List of BaseMessage from a response.

Returns:

A tuple containing whether the agent should be

terminated and a string of termination reason.

Return type:

tuple

reset()[source]#
class camel.terminators.TokenLimitTerminator(token_limit: int)[source]#

Bases: BaseTerminator

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

Parameters:

token_limit (int) – Token limit threshold.

is_terminated(num_tokens: int) Tuple[bool, str | None][source]#

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

Parameters:

num_tokens (int) – Number of tokens.

Returns:

A tuple containing whether the agent should be

terminated and a string of termination reason.

Return type:

tuple

reset()[source]#