camel.societies package#
Submodules#
camel.societies.babyagi_playing module#
- class camel.societies.babyagi_playing.BabyAGI(assistant_role_name: str, user_role_name: str, task_prompt: str = '', task_type: TaskType = TaskType.AI_SOCIETY, max_task_history: int = 10, assistant_agent_kwargs: Dict | None = None, task_specify_agent_kwargs: Dict | None = None, task_creation_agent_kwargs: Dict | None = None, task_prioritization_agent_kwargs: Dict | None = None, sys_msg_generator_kwargs: Dict | None = None, extend_task_specify_meta_dict: Dict | None = None, output_language: str | None = None, message_window_size: int | None = None)[source]#
Bases:
object
The BabyAGI Agent adapted from “Task-driven Autonomous Agent”.
- Parameters:
assistant_role_name (str) – The name of the role played by the assistant.
user_role_name (str) – The name of the role played by the user.
task_prompt (str, optional) – A prompt for the task to be performed. (default:
""
)task_type (TaskType, optional) – The type of task to perform. (default:
TaskType.AI_SOCIETY
)max_task_history (int) – The maximum number of previous tasks information to include in the task agent. (default: :obj:10)
assistant_agent_kwargs (Dict, optional) – Additional arguments to pass to the assistant agent. (default:
None
)task_specify_agent_kwargs (Dict, optional) – Additional arguments to pass to the task specify agent. (default:
None
)task_creation_agent_kwargs (Dict, optional) – Additional arguments to pass to the task creation agent. (default:
None
)task_prioritization_agent_kwargs (Dict, optional) – Additional arguments to pass to the task prioritization agent. (default:
None
)sys_msg_generator_kwargs (Dict, optional) – Additional arguments to pass to the system message generator. (default:
None
)extend_task_specify_meta_dict (Dict, optional) – A dict to extend the task specify meta dict with. (default:
None
)output_language (str, optional) – The language to be output by the agents. (default:
None
)message_window_size (int, optional) – The maximum number of previous messages to include in the context window. If None, no windowing is performed. (default:
None
)
- init_agents(init_assistant_sys_msg: BaseMessage, assistant_agent_kwargs: Dict | None, task_creation_agent_kwargs: Dict | None, task_prioritization_agent_kwargs: Dict | None, output_language: str | None, message_window_size: int | None = None)[source]#
Initialize assistant and user agents with their system messages.
- Parameters:
init_assistant_sys_msg (BaseMessage) – Assistant agent’s initial system message.
assistant_agent_kwargs (Dict, optional) – Additional arguments to pass to the assistant agent.
task_creation_agent_kwargs (Dict, optional) – Additional arguments to pass to the task creation agent.
task_prioritization_agent_kwargs (Dict, optional) – Additional arguments to pass to the task prioritization agent.
output_language (str, optional) – The language to be output by the agents.
message_window_size (int, optional) – The maximum number of previous messages to include in the context window. If None, no windowing is performed. (default:
None
)
- init_specified_task_prompt(assistant_role_name: str, user_role_name: str, task_specify_agent_kwargs: Dict | None, extend_task_specify_meta_dict: Dict | None, output_language: str | None)[source]#
Use a task specify agent to generate a specified task prompt. Generated specified task prompt will be used to replace original task prompt. If there is no task specify agent, specified task prompt will not be generated.
- Parameters:
assistant_role_name (str) – The name of the role played by the assistant.
user_role_name (str) – The name of the role played by the user.
task_specify_agent_kwargs (Dict, optional) – Additional arguments to pass to the task specify agent.
extend_task_specify_meta_dict (Dict, optional) – A dict to extend the task specify meta dict with.
output_language (str, optional) – The language to be output by the agents.
- step() ChatAgentResponse [source]#
BabyAGI agent would pull the first task from the task list, complete the task based on the context, then creates new tasks and re-prioritizes the task list based on the objective and the result of the previous task. It returns assistant message.
- Returns:
it contains the resulting assistant message, whether the assistant agent terminated the conversation, and any additional assistant information.
- Return type:
camel.societies.role_playing module#
- class camel.societies.role_playing.RolePlaying(assistant_role_name: str, user_role_name: str, *, critic_role_name: str = 'critic', task_prompt: str = '', with_task_specify: bool = True, with_task_planner: bool = False, with_critic_in_the_loop: bool = False, critic_criteria: str | None = None, model: BaseModelBackend | None = None, task_type: TaskType = TaskType.AI_SOCIETY, assistant_agent_kwargs: Dict | None = None, user_agent_kwargs: Dict | None = None, task_specify_agent_kwargs: Dict | None = None, task_planner_agent_kwargs: Dict | None = None, critic_kwargs: Dict | None = None, sys_msg_generator_kwargs: Dict | None = None, extend_sys_msg_meta_dicts: List[Dict] | None = None, extend_task_specify_meta_dict: Dict | None = None, output_language: str | None = None)[source]#
Bases:
object
Role playing between two agents.
- Parameters:
assistant_role_name (str) – The name of the role played by the assistant.
user_role_name (str) – The name of the role played by the user.
critic_role_name (str, optional) – The name of the role played by the critic. Role name with
"human"
will set critic as aHuman
agent, else will create aCriticAgent
. (default:"critic"
)task_prompt (str, optional) – A prompt for the task to be performed. (default:
""
)with_task_specify (bool, optional) – Whether to use a task specify agent. (default:
True
)with_task_planner (bool, optional) – Whether to use a task planner agent. (default:
False
)with_critic_in_the_loop (bool, optional) – Whether to include a critic in the loop. (default:
False
)critic_criteria (str, optional) – Critic criteria for the critic agent. If not specified, set the criteria to improve task performance.
model (BaseModelBackend, optional) – The model backend to use for generating responses. If specified, it will override the model in all agents if not specified in agent-specific kwargs. (default:
OpenAIModel
with GPT_4O_MINI)task_type (TaskType, optional) – The type of task to perform. (default:
TaskType.AI_SOCIETY
)assistant_agent_kwargs (Dict, optional) – Additional arguments to pass to the assistant agent. (default:
None
)user_agent_kwargs (Dict, optional) – Additional arguments to pass to the user agent. (default:
None
)task_specify_agent_kwargs (Dict, optional) – Additional arguments to pass to the task specify agent. (default:
None
)task_planner_agent_kwargs (Dict, optional) – Additional arguments to pass to the task planner agent. (default:
None
)critic_kwargs (Dict, optional) – Additional arguments to pass to the critic. (default:
None
)sys_msg_generator_kwargs (Dict, optional) – Additional arguments to pass to the system message generator. (default:
None
)extend_sys_msg_meta_dicts (List[Dict], optional) – A list of dicts to extend the system message meta dicts with. (default:
None
)extend_task_specify_meta_dict (Dict, optional) – A dict to extend the task specify meta dict with. (default:
None
)output_language (str, optional) – The language to be output by the agents. (default:
None
)
- init_chat(init_msg_content: str | None = None) BaseMessage [source]#
Initializes the chat by resetting both of the assistant and user agents. Returns an initial message for the role-playing session.
- Parameters:
init_msg_content (str, optional) – A user-specified initial message. Will be sent to the role-playing session as the initial message. (default:
None
)- Returns:
- A single BaseMessage representing the initial
message.
- Return type:
- step(assistant_msg: BaseMessage) Tuple[ChatAgentResponse, ChatAgentResponse] [source]#
Advances the conversation by taking a message from the assistant, processing it using the user agent, and then processing the resulting message using the assistant agent. Returns a tuple containing the resulting assistant message, whether the assistant agent terminated the conversation, and any additional assistant information, as well as a tuple containing the resulting user message, whether the user agent terminated the conversation, and any additional user information.
- Parameters:
assistant_msg – A BaseMessage representing the message from the assistant.
- Returns:
- A tuple containing two
ChatAgentResponse: the first struct contains the resulting assistant message, whether the assistant agent terminated the conversation, and any additional assistant information; the second struct contains the resulting user message, whether the user agent terminated the conversation, and any additional user information.
- Return type:
Tuple[ChatAgentResponse, ChatAgentResponse]
Subpackages#
- camel.societies.workforce package
- Submodules
- camel.societies.workforce.base module
- camel.societies.workforce.prompts module
- camel.societies.workforce.role_playing_worker module
- camel.societies.workforce.single_agent_worker module
- camel.societies.workforce.task_channel module
Packet
PacketStatus
TaskChannel
TaskChannel.archive_task()
TaskChannel.get_assigned_task_by_assignee()
TaskChannel.get_channel_debug_info()
TaskChannel.get_dependency_ids()
TaskChannel.get_returned_task_by_publisher()
TaskChannel.get_task_by_id()
TaskChannel.post_dependency()
TaskChannel.post_task()
TaskChannel.remove_task()
TaskChannel.return_task()
- camel.societies.workforce.utils module
- camel.societies.workforce.worker module
- camel.societies.workforce.workforce module
- Module contents
Module contents#
- class camel.societies.BabyAGI(assistant_role_name: str, user_role_name: str, task_prompt: str = '', task_type: TaskType = TaskType.AI_SOCIETY, max_task_history: int = 10, assistant_agent_kwargs: Dict | None = None, task_specify_agent_kwargs: Dict | None = None, task_creation_agent_kwargs: Dict | None = None, task_prioritization_agent_kwargs: Dict | None = None, sys_msg_generator_kwargs: Dict | None = None, extend_task_specify_meta_dict: Dict | None = None, output_language: str | None = None, message_window_size: int | None = None)[source]#
Bases:
object
The BabyAGI Agent adapted from “Task-driven Autonomous Agent”.
- Parameters:
assistant_role_name (str) – The name of the role played by the assistant.
user_role_name (str) – The name of the role played by the user.
task_prompt (str, optional) – A prompt for the task to be performed. (default:
""
)task_type (TaskType, optional) – The type of task to perform. (default:
TaskType.AI_SOCIETY
)max_task_history (int) – The maximum number of previous tasks information to include in the task agent. (default: :obj:10)
assistant_agent_kwargs (Dict, optional) – Additional arguments to pass to the assistant agent. (default:
None
)task_specify_agent_kwargs (Dict, optional) – Additional arguments to pass to the task specify agent. (default:
None
)task_creation_agent_kwargs (Dict, optional) – Additional arguments to pass to the task creation agent. (default:
None
)task_prioritization_agent_kwargs (Dict, optional) – Additional arguments to pass to the task prioritization agent. (default:
None
)sys_msg_generator_kwargs (Dict, optional) – Additional arguments to pass to the system message generator. (default:
None
)extend_task_specify_meta_dict (Dict, optional) – A dict to extend the task specify meta dict with. (default:
None
)output_language (str, optional) – The language to be output by the agents. (default:
None
)message_window_size (int, optional) – The maximum number of previous messages to include in the context window. If None, no windowing is performed. (default:
None
)
- init_agents(init_assistant_sys_msg: BaseMessage, assistant_agent_kwargs: Dict | None, task_creation_agent_kwargs: Dict | None, task_prioritization_agent_kwargs: Dict | None, output_language: str | None, message_window_size: int | None = None)[source]#
Initialize assistant and user agents with their system messages.
- Parameters:
init_assistant_sys_msg (BaseMessage) – Assistant agent’s initial system message.
assistant_agent_kwargs (Dict, optional) – Additional arguments to pass to the assistant agent.
task_creation_agent_kwargs (Dict, optional) – Additional arguments to pass to the task creation agent.
task_prioritization_agent_kwargs (Dict, optional) – Additional arguments to pass to the task prioritization agent.
output_language (str, optional) – The language to be output by the agents.
message_window_size (int, optional) – The maximum number of previous messages to include in the context window. If None, no windowing is performed. (default:
None
)
- init_specified_task_prompt(assistant_role_name: str, user_role_name: str, task_specify_agent_kwargs: Dict | None, extend_task_specify_meta_dict: Dict | None, output_language: str | None)[source]#
Use a task specify agent to generate a specified task prompt. Generated specified task prompt will be used to replace original task prompt. If there is no task specify agent, specified task prompt will not be generated.
- Parameters:
assistant_role_name (str) – The name of the role played by the assistant.
user_role_name (str) – The name of the role played by the user.
task_specify_agent_kwargs (Dict, optional) – Additional arguments to pass to the task specify agent.
extend_task_specify_meta_dict (Dict, optional) – A dict to extend the task specify meta dict with.
output_language (str, optional) – The language to be output by the agents.
- step() ChatAgentResponse [source]#
BabyAGI agent would pull the first task from the task list, complete the task based on the context, then creates new tasks and re-prioritizes the task list based on the objective and the result of the previous task. It returns assistant message.
- Returns:
it contains the resulting assistant message, whether the assistant agent terminated the conversation, and any additional assistant information.
- Return type:
- class camel.societies.RolePlaying(assistant_role_name: str, user_role_name: str, *, critic_role_name: str = 'critic', task_prompt: str = '', with_task_specify: bool = True, with_task_planner: bool = False, with_critic_in_the_loop: bool = False, critic_criteria: str | None = None, model: BaseModelBackend | None = None, task_type: TaskType = TaskType.AI_SOCIETY, assistant_agent_kwargs: Dict | None = None, user_agent_kwargs: Dict | None = None, task_specify_agent_kwargs: Dict | None = None, task_planner_agent_kwargs: Dict | None = None, critic_kwargs: Dict | None = None, sys_msg_generator_kwargs: Dict | None = None, extend_sys_msg_meta_dicts: List[Dict] | None = None, extend_task_specify_meta_dict: Dict | None = None, output_language: str | None = None)[source]#
Bases:
object
Role playing between two agents.
- Parameters:
assistant_role_name (str) – The name of the role played by the assistant.
user_role_name (str) – The name of the role played by the user.
critic_role_name (str, optional) – The name of the role played by the critic. Role name with
"human"
will set critic as aHuman
agent, else will create aCriticAgent
. (default:"critic"
)task_prompt (str, optional) – A prompt for the task to be performed. (default:
""
)with_task_specify (bool, optional) – Whether to use a task specify agent. (default:
True
)with_task_planner (bool, optional) – Whether to use a task planner agent. (default:
False
)with_critic_in_the_loop (bool, optional) – Whether to include a critic in the loop. (default:
False
)critic_criteria (str, optional) – Critic criteria for the critic agent. If not specified, set the criteria to improve task performance.
model (BaseModelBackend, optional) – The model backend to use for generating responses. If specified, it will override the model in all agents if not specified in agent-specific kwargs. (default:
OpenAIModel
with GPT_4O_MINI)task_type (TaskType, optional) – The type of task to perform. (default:
TaskType.AI_SOCIETY
)assistant_agent_kwargs (Dict, optional) – Additional arguments to pass to the assistant agent. (default:
None
)user_agent_kwargs (Dict, optional) – Additional arguments to pass to the user agent. (default:
None
)task_specify_agent_kwargs (Dict, optional) – Additional arguments to pass to the task specify agent. (default:
None
)task_planner_agent_kwargs (Dict, optional) – Additional arguments to pass to the task planner agent. (default:
None
)critic_kwargs (Dict, optional) – Additional arguments to pass to the critic. (default:
None
)sys_msg_generator_kwargs (Dict, optional) – Additional arguments to pass to the system message generator. (default:
None
)extend_sys_msg_meta_dicts (List[Dict], optional) – A list of dicts to extend the system message meta dicts with. (default:
None
)extend_task_specify_meta_dict (Dict, optional) – A dict to extend the task specify meta dict with. (default:
None
)output_language (str, optional) – The language to be output by the agents. (default:
None
)
- init_chat(init_msg_content: str | None = None) BaseMessage [source]#
Initializes the chat by resetting both of the assistant and user agents. Returns an initial message for the role-playing session.
- Parameters:
init_msg_content (str, optional) – A user-specified initial message. Will be sent to the role-playing session as the initial message. (default:
None
)- Returns:
- A single BaseMessage representing the initial
message.
- Return type:
- step(assistant_msg: BaseMessage) Tuple[ChatAgentResponse, ChatAgentResponse] [source]#
Advances the conversation by taking a message from the assistant, processing it using the user agent, and then processing the resulting message using the assistant agent. Returns a tuple containing the resulting assistant message, whether the assistant agent terminated the conversation, and any additional assistant information, as well as a tuple containing the resulting user message, whether the user agent terminated the conversation, and any additional user information.
- Parameters:
assistant_msg – A BaseMessage representing the message from the assistant.
- Returns:
- A tuple containing two
ChatAgentResponse: the first struct contains the resulting assistant message, whether the assistant agent terminated the conversation, and any additional assistant information; the second struct contains the resulting user message, whether the user agent terminated the conversation, and any additional user information.
- Return type:
Tuple[ChatAgentResponse, ChatAgentResponse]