camel package#

Subpackages#

Submodules#

camel.generators module#

class camel.generators.AISocietyTaskPromptGenerator(num_tasks: int = 10)[source]#

Bases: object

from_role_files(assistant_role_names_path: str = 'data/ai_society/assistant_roles.txt', user_role_names_path: str = 'data/ai_society/user_roles.txt') Generator[Tuple[str, Tuple[str, str]], None, None][source]#
from_role_generator(role_generator: Generator[Tuple, None, None]) Generator[Tuple[str, Tuple[str, str]], None, None][source]#
class camel.generators.CodeTaskPromptGenerator(num_tasks: int = 50)[source]#

Bases: object

from_role_files(languages_path: str = 'data/code/languages.txt', domains_path: str = 'data/code/domains.txt') Generator[Tuple[TextPrompt, str, str], None, None][source]#
from_role_generator(role_generator: Generator[Tuple, None, None]) Generator[str, None, None][source]#
class camel.generators.RoleNameGenerator(assistant_role_names_path: str = 'data/ai_society/assistant_roles.txt', user_role_names_path: str = 'data/ai_society/user_roles.txt', assistant_role_names: List[str] | None = None, user_role_names: List[str] | None = None)[source]#

Bases: object

from_role_files() Generator[Tuple, None, None][source]#
class camel.generators.SingleTxtGenerator(text_file_path: str)[source]#

Bases: object

from_role_files() Generator[str, None, None][source]#
class camel.generators.SystemMessageGenerator(task_type: TaskType = TaskType.AI_SOCIETY, sys_prompts: Dict[RoleType, str] | None = None, sys_msg_meta_dict_keys: Set[str] | None = None)[source]#

Bases: object

System message generator for agents.

Parameters:
  • task_type (TaskType, optional) – The task type. (default: TaskType.AI_SOCIETY)

  • sys_prompts (Optional[Dict[RoleType, str]], optional) – The prompts of the system messages for each role type. (default: None)

  • sys_msg_meta_dict_keys (Optional[Set[str]], optional) – The set of keys of the meta dictionary used to fill the prompts. (default: None)

from_dict(meta_dict: Dict[str, str], role_tuple: Tuple[str, RoleType] = ('', RoleType.DEFAULT)) BaseMessage[source]#

Generates a system message from a dictionary.

Parameters:
  • meta_dict (Dict[str, str]) – The dictionary containing the information to generate the system message.

  • role_tuple (Tuple[str, RoleType], optional) – The tuple containing the role name and role type. (default: (“”, RoleType.DEFAULT))

Returns:

The generated system message.

Return type:

BaseMessage

from_dicts(meta_dicts: List[Dict[str, str]], role_tuples: List[Tuple[str, RoleType]]) List[BaseMessage][source]#

Generates a list of system messages from a list of dictionaries.

Parameters:
  • meta_dicts (List[Dict[str, str]]) – A list of dictionaries containing the information to generate the system messages.

  • role_tuples (List[Tuple[str, RoleType]]) – A list of tuples containing the role name and role type for each system message.

Returns:

A list of generated system messages.

Return type:

List[BaseMessage]

Raises:

ValueError – If the number of meta_dicts and role_tuples are different.

validate_meta_dict_keys(meta_dict: Dict[str, str]) None[source]#

Validates the keys of the meta_dict.

Parameters:

meta_dict (Dict[str, str]) – The dictionary to validate.

camel.human module#

class camel.human.Human(name: str = 'Kill Switch Engineer', logger_color: Any = '\x1b[35m')[source]#

Bases: object

A class representing a human user.

Parameters:
  • name (str) – The name of the human user. (default: "Kill Switch Engineer").

  • logger_color (Any) – The color of the menu options displayed to the user. (default: Fore.MAGENTA)

name#

The name of the human user.

Type:

str

logger_color#

The color of the menu options displayed to the user.

Type:

Any

input_button#

The text displayed for the input button.

Type:

str

kill_button#

The text displayed for the kill button.

Type:

str

options_dict#

A dictionary containing the options displayed to the user.

Type:

Dict[str, str]

display_options(messages: Sequence[BaseMessage]) None[source]#

Displays the options to the user.

Parameters:

messages (Sequence[BaseMessage]) – A list of BaseMessage objects.

Returns:

None

get_input() str[source]#

Gets the input from the user.

Returns:

The user’s input.

Return type:

str

parse_input(human_input: str) str[source]#

Parses the user’s input and returns a BaseMessage object.

Parameters:

human_input (str) – The user’s input.

Returns:

A str object representing the user’s input.

Return type:

content

reduce_step(messages: Sequence[BaseMessage]) ChatAgentResponse[source]#

Performs one step of the conversation by displaying options to the user, getting their input, and parsing their choice.

Parameters:

messages (Sequence[BaseMessage]) – A list of BaseMessage objects.

Returns:

A ChatAgentResponse object representing the

user’s choice.

Return type:

ChatAgentResponse

Module contents#