🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
[BUG] Solved the name inconsistancy bugs for ChatAgent (#366)
FUYICC2431c4eeb9d5
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.pyindex 5bde843cd..90f2e9b1a 100644--- a/camel/agents/chat_agent.py+++ b/camel/agents/chat_agent.py@@ -72,7 +72,7 @@ class ChatAgent(BaseAgent):Args:system_message (BaseMessage): The system message for the chat agent.- model (ModelType, optional): The LLM model to use for generating+ model_type (ModelType, optional): The LLM model to use for generatingresponses. (default :obj:`ModelType.GPT_3_5_TURBO`)model_config (BaseConfig, optional): Configuration options for theLLM model. (default: :obj:`None`)@@ -98,7 +98,7 @@ class ChatAgent(BaseAgent):def __init__(self,system_message: BaseMessage,- model: Optional[ModelType] = None,+ model_type: Optional[ModelType] = None,model_config: Optional[BaseConfig] = None,memory: Optional[BaseMemory] = None,message_window_size: Optional[int] = None,@@ -116,8 +116,8 @@ class ChatAgent(BaseAgent):if self.output_language is not None:self.set_output_language(self.output_language)- self.model: ModelType = (model if model is not None else- ModelType.GPT_3_5_TURBO)+ self.model_type: ModelType = (model_type if model_type is not None else+ ModelType.GPT_3_5_TURBO)self.func_dict: Dict[str, Callable] = {}if function_list is not None:@@ -126,7 +126,7 @@ class ChatAgent(BaseAgent):self.model_config = model_config or ChatGPTConfig()self.model_backend: BaseModelBackend = ModelFactory.create(- self.model, self.model_config.__dict__)+ self.model_type, self.model_config.__dict__)self.model_token_limit = token_limit or self.model_backend.token_limitcontext_creator = ScoreBasedContextCreator(self.model_backend.token_counter,@@ -520,7 +520,7 @@ class ChatAgent(BaseAgent):Returns:dict: Usage dictionary."""- encoding = get_model_encoding(self.model.value_for_tiktoken)+ encoding = get_model_encoding(self.model_type.value_for_tiktoken)completion_tokens = 0for message in output_messages:completion_tokens += len(encoding.encode(message.content))@@ -535,4 +535,6 @@ class ChatAgent(BaseAgent):Returns:str: The string representation of the :obj:`ChatAgent`."""- return f"ChatAgent({self.role_name}, {self.role_type}, {self.model})"+ return (+ f"ChatAgent({self.role_name}, {self.role_type}, {self.model_type})"+ )diff --git a/camel/agents/critic_agent.py b/camel/agents/critic_agent.pyindex db373cb7e..19f25a98c 100644--- a/camel/agents/critic_agent.py+++ b/camel/agents/critic_agent.py@@ -31,7 +31,7 @@ class CriticAgent(ChatAgent):Args:system_message (BaseMessage): The system message for the criticagent.- model (ModelType, optional): The LLM model to use for generating+ model_type (ModelType, optional): The LLM model to use for generatingresponses. (default :obj:`ModelType.GPT_3_5_TURBO`)model_config (Any, optional): Configuration options for the LLM model.(default: :obj:`None`)@@ -48,7 +48,7 @@ class CriticAgent(ChatAgent):def __init__(self,system_message: BaseMessage,- model: ModelType = ModelType.GPT_3_5_TURBO,+ model_type: ModelType = ModelType.GPT_3_5_TURBO,model_config: Optional[Any] = None,memory: Optional[BaseMemory] = None,message_window_size: int = 6,@@ -56,7 +56,7 @@ class CriticAgent(ChatAgent):verbose: bool = False,logger_color: Any = Fore.MAGENTA,) -> None:- super().__init__(system_message, model=model,+ super().__init__(system_message, model_type=model_type,model_config=model_config, memory=memory,message_window_size=message_window_size)self.options_dict: Dict[str, str] = dict()diff --git a/camel/agents/embodied_agent.py b/camel/agents/embodied_agent.pyindex bfb073a36..33ae6ec1d 100644--- a/camel/agents/embodied_agent.py+++ b/camel/agents/embodied_agent.py@@ -27,7 +27,7 @@ class EmbodiedAgent(ChatAgent):Args:system_message (BaseMessage): The system message for the chat agent.- model (ModelType, optional): The LLM model to use for generating+ model_type (ModelType, optional): The LLM model to use for generatingresponses. (default :obj:`ModelType.GPT_4`)model_config (Any, optional): Configuration options for the LLM model.(default: :obj:`None`)@@ -44,7 +44,7 @@ class EmbodiedAgent(ChatAgent):def __init__(self,system_message: BaseMessage,- model: ModelType = ModelType.GPT_4,+ model_type: ModelType = ModelType.GPT_4,model_config: Optional[Any] = None,message_window_size: Optional[int] = None,action_space: Optional[List[BaseToolAgent]] = None,@@ -52,7 +52,8 @@ class EmbodiedAgent(ChatAgent):logger_color: Any = Fore.MAGENTA,) -> None:default_action_space = [- HuggingFaceToolAgent('hugging_face_tool_agent', model=model.value),+ HuggingFaceToolAgent('hugging_face_tool_agent',+ model_type=model_type.value),]self.action_space = action_space or default_action_spaceaction_space_prompt = self.get_action_space_prompt()@@ -62,7 +63,7 @@ class EmbodiedAgent(ChatAgent):self.logger_color = logger_colorsuper().__init__(system_message=system_message,- model=model,+ model_type=model_type,model_config=model_config,message_window_size=message_window_size,)diff --git a/camel/agents/role_assignment_agent.py b/camel/agents/role_assignment_agent.pyindex b24010788..344e8ea5d 100644--- a/camel/agents/role_assignment_agent.py+++ b/camel/agents/role_assignment_agent.py@@ -27,15 +27,15 @@ class RoleAssignmentAgent(ChatAgent):role names.Args:- model (ModelType, optional): The type of model to use for the agent.- (default: :obj:`ModelType.GPT_3_5_TURBO`)+ model_type (ModelType, optional): The type of model to use for the+ agent. (default: :obj:`ModelType.GPT_3_5_TURBO`)model_config (Any, optional): The configuration for the model.(default: :obj:`None`)"""def __init__(self,- model: ModelType = ModelType.GPT_3_5_TURBO,+ model_type: ModelType = ModelType.GPT_3_5_TURBO,model_config: Optional[Any] = None,) -> None:system_message = BaseMessage(@@ -44,7 +44,7 @@ class RoleAssignmentAgent(ChatAgent):meta_dict=None,content="You assign roles based on tasks.",)- super().__init__(system_message, model, model_config)+ super().__init__(system_message, model_type, model_config)def run(self,diff --git a/camel/agents/task_agent.py b/camel/agents/task_agent.pyindex 01291555c..11851e255 100644--- a/camel/agents/task_agent.py+++ b/camel/agents/task_agent.py@@ -30,8 +30,8 @@ class TaskSpecifyAgent(ChatAgent):task_specify_prompt (TextPrompt): The prompt for specifying the task.Args:- model (ModelType, optional): The type of model to use for the agent.- (default: :obj:`ModelType.GPT_3_5_TURBO`)+ model_type (ModelType, optional): The type of model to use for the+ agent. (default: :obj:`ModelType.GPT_3_5_TURBO`)task_type (TaskType, optional): The type of task for which to generatea prompt. (default: :obj:`TaskType.AI_SOCIETY`)model_config (Any, optional): The configuration for the model.@@ -47,7 +47,7 @@ class TaskSpecifyAgent(ChatAgent):def __init__(self,- model: Optional[ModelType] = None,+ model_type: Optional[ModelType] = None,task_type: TaskType = TaskType.AI_SOCIETY,model_config: Optional[Any] = None,task_specify_prompt: Optional[Union[str, TextPrompt]] = None,@@ -74,7 +74,7 @@ class TaskSpecifyAgent(ChatAgent):content="You can make a task more specific.",)- super().__init__(system_message, model=model,+ super().__init__(system_message, model_type=model_type,model_config=model_config,output_language=output_language)@@ -124,8 +124,8 @@ class TaskPlannerAgent(ChatAgent):the task into subtasks.Args:- model (ModelType, optional): The type of model to use for the agent.- (default: :obj:`ModelType.GPT_3_5_TURBO`)+ model_type (ModelType, optional): The type of model to use for the+ agent. (default: :obj:`ModelType.GPT_3_5_TURBO`)model_config (Any, optional): The configuration for the model.(default: :obj:`None`)output_language (str, optional): The language to be output by the@@ -134,7 +134,7 @@ class TaskPlannerAgent(ChatAgent):def __init__(self,- model: Optional[ModelType] = None,+ model_type: Optional[ModelType] = None,model_config: Optional[Any] = None,output_language: Optional[str] = None,) -> None:@@ -148,7 +148,7 @@ class TaskPlannerAgent(ChatAgent):content="You are a helpful task planner.",)- super().__init__(system_message, model, model_config,+ super().__init__(system_message, model_type, model_config,output_language=output_language)def run(@@ -197,8 +197,8 @@ class TaskCreationAgent(ChatAgent):role_name (str): The role name of the Agent to create the task.objective (Union[str, TextPrompt]): The objective of the Agent toperform the task.- model (ModelType, optional): The type of model to use for the agent.- (default: :obj:`ModelType.GPT_3_5_TURBO`)+ model_type (ModelType, optional): The type of model to use for the+ agent. (default: :obj:`ModelType.GPT_3_5_TURBO`)model_config (Any, optional): The configuration for the model.(default: :obj:`None`)output_language (str, optional): The language to be output by the@@ -214,7 +214,7 @@ class TaskCreationAgent(ChatAgent):self,role_name: str,objective: Union[str, TextPrompt],- model: Optional[ModelType] = None,+ model_type: Optional[ModelType] = None,model_config: Optional[Any] = None,output_language: Optional[str] = None,message_window_size: Optional[int] = None,@@ -253,7 +253,7 @@ Be concrete.content="You are a helpful task creator.",)- super().__init__(system_message, model, model_config,+ super().__init__(system_message, model_type, model_config,output_language=output_language,message_window_size=message_window_size)@@ -303,8 +303,8 @@ class TaskPrioritizationAgent(ChatAgent):Args:objective (Union[str, TextPrompt]): The objective of the Agent toperform the task.- model (ModelType, optional): The type of model to use for the agent.- (default: :obj:`ModelType.GPT_3_5_TURBO`)+ model_type (ModelType, optional): The type of model to use for the+ agent. (default: :obj:`ModelType.GPT_3_5_TURBO`)model_config (Any, optional): The configuration for the model.(default: :obj:`None`)output_language (str, optional): The language to be output by the@@ -317,7 +317,7 @@ class TaskPrioritizationAgent(ChatAgent):def __init__(self,objective: Union[str, TextPrompt],- model: Optional[ModelType] = None,+ model_type: Optional[ModelType] = None,model_config: Optional[Any] = None,output_language: Optional[str] = None,message_window_size: Optional[int] = None,@@ -350,7 +350,7 @@ with any other output.""")content="You are a helpful task prioritizer.",)- super().__init__(system_message, model, model_config,+ super().__init__(system_message, model_type, model_config,output_language=output_language,message_window_size=message_window_size)diff --git a/camel/societies/role_playing.py b/camel/societies/role_playing.pyindex b3a660553..3867b0589 100644--- a/camel/societies/role_playing.py+++ b/camel/societies/role_playing.py@@ -168,7 +168,8 @@ class RolePlaying:if self.model_type is not None:if task_specify_agent_kwargs is None:task_specify_agent_kwargs = {}- task_specify_agent_kwargs.update(dict(model=self.model_type))+ task_specify_agent_kwargs.update(+ dict(model_type=self.model_type))task_specify_agent = TaskSpecifyAgent(task_type=self.task_type,output_language=output_language,@@ -199,7 +200,8 @@ class RolePlaying:if self.model_type is not None:if task_planner_agent_kwargs is None:task_planner_agent_kwargs = {}- task_planner_agent_kwargs.update(dict(model=self.model_type))+ task_planner_agent_kwargs.update(+ dict(model_type=self.model_type))task_planner_agent = TaskPlannerAgent(output_language=output_language,**(task_planner_agent_kwargs or {}),@@ -286,10 +288,10 @@ class RolePlaying:if self.model_type is not None:if assistant_agent_kwargs is None:assistant_agent_kwargs = {}- assistant_agent_kwargs.update(dict(model=self.model_type))+ assistant_agent_kwargs.update(dict(model_type=self.model_type))if user_agent_kwargs is None:user_agent_kwargs = {}- user_agent_kwargs.update(dict(model=self.model_type))+ user_agent_kwargs.update(dict(model_type=self.model_type))self.assistant_agent = ChatAgent(init_assistant_sys_msg,@@ -342,7 +344,7 @@ class RolePlaying:if self.model_type is not None:if critic_kwargs is None:critic_kwargs = {}- critic_kwargs.update(dict(model=self.model_type))+ critic_kwargs.update(dict(model_type=self.model_type))self.critic = CriticAgent(self.critic_sys_msg,**(critic_kwargs or {}),diff --git a/camel/utils/commons.py b/camel/utils/commons.pyindex d9a1f8fba..8ac475f47 100644--- a/camel/utils/commons.py+++ b/camel/utils/commons.py@@ -55,9 +55,9 @@ def openai_api_key_required(func: F) -> F:@wraps(func)def wrapper(self, *args, **kwargs):- if hasattr(self, "model") and self.model == ModelType.STUB:+ if hasattr(self, "model") and self.model_type == ModelType.STUB:return func(self, *args, **kwargs)- elif self.model.is_open_source:+ elif self.model_type.is_open_source:return func(self, *args, **kwargs)elif 'OPENAI_API_KEY' in os.environ:return func(self, *args, **kwargs)diff --git a/examples/ai_society/babyagi_playing.py b/examples/ai_society/babyagi_playing.pyindex c97ab14e7..8a0f1f725 100644--- a/examples/ai_society/babyagi_playing.py+++ b/examples/ai_society/babyagi_playing.py@@ -23,10 +23,10 @@ def main(model_type=None, chat_turn_limit=15) -> None:task_prompt = "Develop a trading bot for the stock market"babyagi_session = BabyAGI(assistant_role_name="Python Programmer",- assistant_agent_kwargs=dict(model=model_type),+ assistant_agent_kwargs=dict(model_type=model_type),user_role_name="Stock Trader",task_prompt=task_prompt,- task_specify_agent_kwargs=dict(model=model_type),+ task_specify_agent_kwargs=dict(model_type=model_type),message_window_size=5,)diff --git a/examples/ai_society/role_playing.py b/examples/ai_society/role_playing.pyindex 478fb34c5..b08880249 100644--- a/examples/ai_society/role_playing.py+++ b/examples/ai_society/role_playing.py@@ -17,16 +17,16 @@ from camel.societies import RolePlayingfrom camel.utils import print_text_animated-def main(model_type=None) -> None:+def main(model_type=None, chat_turn_limit=50) -> None:task_prompt = "Develop a trading bot for the stock market"role_play_session = RolePlaying(assistant_role_name="Python Programmer",- assistant_agent_kwargs=dict(model=model_type),+ assistant_agent_kwargs=dict(model_type=model_type),user_role_name="Stock Trader",- user_agent_kwargs=dict(model=model_type),+ user_agent_kwargs=dict(model_type=model_type),task_prompt=task_prompt,with_task_specify=True,- task_specify_agent_kwargs=dict(model=model_type),+ task_specify_agent_kwargs=dict(model_type=model_type),)print(@@ -41,7 +41,7 @@ def main(model_type=None) -> None:f"Specified task prompt:\n{role_play_session.specified_task_prompt}\n")print(Fore.RED + f"Final task prompt:\n{role_play_session.task_prompt}\n")- chat_turn_limit, n = 50, 0+ n = 0input_assistant_msg, _ = role_play_session.init_chat()while n < chat_turn_limit:n += 1diff --git a/examples/ai_society/role_playing_multi_lingual.py b/examples/ai_society/role_playing_multi_lingual.pyindex 70ee65375..f66d0997a 100644--- a/examples/ai_society/role_playing_multi_lingual.py+++ b/examples/ai_society/role_playing_multi_lingual.py@@ -21,12 +21,12 @@ def main(model_type=None) -> None:task_prompt = "Develop a trading bot for the stock market"role_play_session = RolePlaying(assistant_role_name="Python Programmer",- assistant_agent_kwargs=dict(model=model_type),+ assistant_agent_kwargs=dict(model_type=model_type),user_role_name="Stock Trader",- user_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO),+ user_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO),task_prompt=task_prompt,with_task_specify=True,- task_specify_agent_kwargs=dict(model=model_type),+ task_specify_agent_kwargs=dict(model_type=model_type),output_language="Chinese", # Arabic, French, Spanish, ...)diff --git a/examples/ai_society/task_generation.py b/examples/ai_society/task_generation.pyindex ec0feae5c..378b666f1 100644--- a/examples/ai_society/task_generation.py+++ b/examples/ai_society/task_generation.py@@ -30,7 +30,7 @@ def generate_tasks(role_names: str, task_generator_prompt: str,assistant_sys_msg = sys_msg_generator.from_dict(dict(), role_tuple=("Task Generator", RoleType.DEFAULT))- assistant_agent = ChatAgent(assistant_sys_msg, model=model)+ assistant_agent = ChatAgent(assistant_sys_msg, model_type=model)user_msg = BaseMessage.make_user_message(role_name="Task Generator",content=task_generator_prompt)diff --git a/examples/code/generate_meta_data.py b/examples/code/generate_meta_data.pyindex 3f690da50..804393d74 100644--- a/examples/code/generate_meta_data.py+++ b/examples/code/generate_meta_data.py@@ -26,7 +26,7 @@ def generate_meta_data(meta_data: str, num: int = 50, model=None):role_name="Assistant",content="You are a helpful assistant.",)- agent = ChatAgent(assistant_sys_msg, model=model)+ agent = ChatAgent(assistant_sys_msg, model_type=model)agent.reset()user_msg = BaseMessage.make_user_message(diff --git a/examples/code/role_playing.py b/examples/code/role_playing.pyindex 78feac869..67d621d4d 100644--- a/examples/code/role_playing.py+++ b/examples/code/role_playing.py@@ -18,19 +18,19 @@ from camel.types import TaskTypefrom camel.utils import print_text_animated-def main(model_type=None) -> None:+def main(model_type=None, chat_turn_limit=50) -> None:task_prompt = "Develop a poll app"language = "JavaScript"domain = "Sociology"meta_dict = {"language": language, "domain": domain}role_play_session = RolePlaying(assistant_role_name=f"{language} Programmer",- assistant_agent_kwargs=dict(model=model_type),+ assistant_agent_kwargs=dict(model_type=model_type),user_role_name=f"Person working in {domain}",- user_agent_kwargs=dict(model=model_type),+ user_agent_kwargs=dict(model_type=model_type),task_prompt=task_prompt,with_task_specify=True,- task_specify_agent_kwargs=dict(model=model_type),+ task_specify_agent_kwargs=dict(model_type=model_type),task_type=TaskType.CODE,extend_sys_msg_meta_dicts=[meta_dict, meta_dict],extend_task_specify_meta_dict=meta_dict,@@ -48,7 +48,7 @@ def main(model_type=None) -> None:f"Specified task prompt:\n{role_play_session.specified_task_prompt}\n")print(Fore.RED + f"Final task prompt:\n{role_play_session.task_prompt}\n")- chat_turn_limit, n = 50, 0+ n = 0input_assistant_msg, _ = role_play_session.init_chat()while n < chat_turn_limit:n += 1diff --git a/examples/code/task_generation.py b/examples/code/task_generation.pyindex 39316a051..a24aabd55 100644--- a/examples/code/task_generation.py+++ b/examples/code/task_generation.py@@ -26,7 +26,7 @@ def generate_tasks(task_generator_prompt: str, language: str, domain: str,sys_msg_generator = SystemMessageGenerator(task_type=TaskType.DEFAULT)assistant_sys_msg = sys_msg_generator.from_dict(dict(), role_tuple=("Task Generator", RoleType.DEFAULT))- assistant_agent = ChatAgent(assistant_sys_msg, model=model)+ assistant_agent = ChatAgent(assistant_sys_msg, model_type=model)user_msg = BaseMessage.make_user_message(role_name="Task Generator",content=task_generator_prompt)diff --git a/examples/embodiment/hugging_face_tool.py b/examples/embodiment/hugging_face_tool.pyindex 5e9db6ee6..e89f99f98 100644--- a/examples/embodiment/hugging_face_tool.py+++ b/examples/embodiment/hugging_face_tool.py@@ -30,7 +30,7 @@ def main():action_space = [HuggingFaceToolAgent('hugging_face_tool_agent',- model=ModelType.GPT_4.value,+ model_type=ModelType.GPT_4.value,remote=True,)]diff --git a/examples/evaluation/single_agent.py b/examples/evaluation/single_agent.pyindex 4df421b85..60e9937e8 100644--- a/examples/evaluation/single_agent.py+++ b/examples/evaluation/single_agent.py@@ -55,7 +55,7 @@ def generate_questions(examples: str, category: str, save_file_name: str,role_name="Assistant",content="You are a helpful assistant.",)- agent = ChatAgent(assistant_sys_msg, model=model)+ agent = ChatAgent(assistant_sys_msg, model_type=model)agent.reset()user_msg = BaseMessage.make_user_message(role_name="User", content=prompt)diff --git a/examples/function_call/role_playing_with_function.py b/examples/function_call/role_playing_with_function.pyindex c402caf37..352eaa4fa 100644--- a/examples/function_call/role_playing_with_function.py+++ b/examples/function_call/role_playing_with_function.py@@ -23,7 +23,7 @@ from camel.types import ModelTypefrom camel.utils import print_text_animated-def main(model_type=ModelType.GPT_4) -> None:+def main(model_type=ModelType.GPT_4, chat_turn_limit=10) -> None:task_prompt = ("Assuming the current year is 2023, estimate KAUST's ""current age and then add 10 more years to this age, ""and get the current weather of the city where KAUST "@@ -41,12 +41,12 @@ def main(model_type=ModelType.GPT_4) -> None:assistant_role_name="Searcher",user_role_name="Professor",assistant_agent_kwargs=dict(- model=model_type,+ model_type=model_type,model_config=assistant_model_config,function_list=function_list,),user_agent_kwargs=dict(- model=model_type,+ model_type=model_type,model_config=user_model_config,),task_prompt=task_prompt,@@ -65,7 +65,7 @@ def main(model_type=ModelType.GPT_4) -> None:f"Specified task prompt:\n{role_play_session.specified_task_prompt}\n")print(Fore.RED + f"Final task prompt:\n{role_play_session.task_prompt}\n")- chat_turn_limit, n = 10, 0+ n = 0input_assistant_msg, _ = role_play_session.init_chat()while n < chat_turn_limit:n += 1diff --git a/examples/misalignment/single_agent.py b/examples/misalignment/single_agent.pyindex e49afda49..61596be5a 100644--- a/examples/misalignment/single_agent.py+++ b/examples/misalignment/single_agent.py@@ -26,7 +26,7 @@ def main(model=None) -> None:role_name="Assistant",content=sys_prompt,)- agent = ChatAgent(assistant_sys_msg, model=model)+ agent = ChatAgent(assistant_sys_msg, model_type=model)agent.reset()user_msg = BaseMessage.make_user_message(role_name="User", content=prompt)diff --git a/examples/open_source_models/role_playing_with_open_source_model.py b/examples/open_source_models/role_playing_with_open_source_model.pyindex 1615769da..f6b227c84 100644--- a/examples/open_source_models/role_playing_with_open_source_model.py+++ b/examples/open_source_models/role_playing_with_open_source_model.py@@ -19,12 +19,13 @@ from camel.types import ModelTypefrom camel.utils import print_text_animated-def main(model_type=None, model_path=" ", server_url=" ") -> None:+def main(model_type=None, chat_turn_limit=50, model_path=" ",+ server_url=" ") -> None:task_prompt = "Develop a trading bot for the stock market"agent_kwargs = {role: dict(- model=model_type,+ model_type=model_type,model_config=OpenSourceConfig(model_path=model_path,server_url=server_url,@@ -56,7 +57,7 @@ def main(model_type=None, model_path=" ", server_url=" ") -> None:f"Specified task prompt:\n{role_play_session.specified_task_prompt}\n")print(Fore.RED + f"Final task prompt:\n{role_play_session.task_prompt}\n")- chat_turn_limit, n = 50, 0+ n = 0input_assistant_msg, _ = role_play_session.init_chat()while n < chat_turn_limit:n += 1diff --git a/examples/role_description/role_generation.py b/examples/role_description/role_generation.pyindex 7353b1af7..22cd1f537 100644--- a/examples/role_description/role_generation.py+++ b/examples/role_description/role_generation.py@@ -22,7 +22,7 @@ def main(model_type=None, num_roles=3) -> None:model_config_description = ChatGPTConfig()role_description_agent = RoleAssignmentAgent(- model=model_type, model_config=model_config_description)+ model_type=model_type, model_config=model_config_description)role_description_dict = role_description_agent.run(task_prompt=task_prompt,num_roles=num_roles)diff --git a/examples/role_description/role_playing_with_role_description.py b/examples/role_description/role_playing_with_role_description.pyindex c6820997d..2905b33a0 100644--- a/examples/role_description/role_playing_with_role_description.py+++ b/examples/role_description/role_playing_with_role_description.py@@ -23,12 +23,13 @@ AI_ASSISTANT_ROLE_INDEX = 0AI_USER_ROLE_INDEX = 1-def main(model_type_for_role_generation=None, model_type=None) -> None:+def main(model_type_for_role_generation=None, model_type=None,+ chat_turn_limit=50) -> None:task_prompt = "Develop a trading bot for the stock market."model_config_description = ChatGPTConfig()role_description_agent = RoleAssignmentAgent(- model=model_type_for_role_generation,+ model_type=model_type_for_role_generation,model_config=model_config_description)role_description_dict = (role_description_agent.run(@@ -53,7 +54,7 @@ def main(model_type_for_role_generation=None, model_type=None) -> None:model_type=model_type,task_type=TaskType.ROLE_DESCRIPTION, # Score for role descriptionwith_task_specify=True,- task_specify_agent_kwargs=dict(model=model_type),+ task_specify_agent_kwargs=dict(model_type=model_type),extend_sys_msg_meta_dicts=sys_msg_meta_dicts,)@@ -75,7 +76,7 @@ def main(model_type_for_role_generation=None, model_type=None) -> None:f"Specified task prompt:\n{role_play_session.specified_task_prompt}\n")print(Fore.RED + f"Final task prompt:\n{role_play_session.task_prompt}\n")- chat_turn_limit, n = 50, 0+ n = 0input_assistant_msg, _ = role_play_session.init_chat()while n < chat_turn_limit:n += 1diff --git a/examples/single_agent.py b/examples/single_agent.pyindex a1dbd2e26..b1b9c721e 100644--- a/examples/single_agent.py+++ b/examples/single_agent.py@@ -26,7 +26,7 @@ def main(key: str = 'generate_users', num_roles: int = 50, model=None):role_name="Assistant",content="You are a helpful assistant.",)- agent = ChatAgent(assistant_sys_msg, model=model)+ agent = ChatAgent(assistant_sys_msg, model_type=model)agent.reset()user_msg = BaseMessage.make_user_message(role_name="User", content=prompt)diff --git a/examples/summarization/gpt_solution_extraction.py b/examples/summarization/gpt_solution_extraction.pyindex 5a7a5079d..146ac6613 100644--- a/examples/summarization/gpt_solution_extraction.py+++ b/examples/summarization/gpt_solution_extraction.py@@ -118,7 +118,7 @@ def solution_extraction(conversation: Dict, flattened_conversation: str,role_name="Solution Extractor", content=assistant_sys_msg_prompt)# We use GPT4 because it has a longer context length- agent = ChatAgent(assistant_sys_msg, model=ModelType.GPT_4)+ agent = ChatAgent(assistant_sys_msg, model_type=ModelType.GPT_4)agent.reset()prompt = "Here is the conversation:" + flattened_conversationdiff --git a/examples/test/test_ai_society_example.py b/examples/test/test_ai_society_example.pyindex e52725e5a..b7a4bd6c1 100644--- a/examples/test/test_ai_society_example.py+++ b/examples/test/test_ai_society_example.py@@ -21,15 +21,17 @@ from camel.types import ModelTypedef test_ai_society_role_playing_example():with patch('time.sleep', return_value=None):- examples.ai_society.role_playing.main(ModelType.STUB)+ examples.ai_society.role_playing.main(ModelType.STUB,+ chat_turn_limit=2)def test_role_playing_with_function_example():with patch('time.sleep', return_value=None):- examples.function_call.role_playing_with_function.main(ModelType.STUB)+ examples.function_call.role_playing_with_function.main(+ ModelType.STUB, chat_turn_limit=2)def test_role_playing_with_open_source_model():with patch('time.sleep', return_value=None):examples.open_source_models.role_playing_with_open_source_model.main(- ModelType.STUB)+ ModelType.STUB, chat_turn_limit=2)diff --git a/examples/test/test_babyagi_example.py b/examples/test/test_babyagi_example.pyindex 4a2a44d90..15b30c5bd 100644--- a/examples/test/test_babyagi_example.py+++ b/examples/test/test_babyagi_example.py@@ -12,6 +12,7 @@# limitations under the License.# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========import pytest+from mock import patchimport examples.ai_society.babyagi_playingfrom camel.types import ModelType@@ -24,5 +25,6 @@ parametrize = pytest.mark.parametrize('model', [@parametrizedef test_ai_society_babyagi_playing_example(model):- examples.ai_society.babyagi_playing.main(model_type=model,- chat_turn_limit=2)+ with patch('time.sleep', return_value=None):+ examples.ai_society.babyagi_playing.main(model_type=model,+ chat_turn_limit=2)diff --git a/examples/test/test_code_example.py b/examples/test/test_code_example.pyindex 20fb7f7fd..7f325c4e9 100644--- a/examples/test/test_code_example.py+++ b/examples/test/test_code_example.py@@ -19,4 +19,4 @@ from camel.types import ModelTypedef test_code_role_playing_example():with patch('time.sleep', return_value=None):- examples.code.role_playing.main(ModelType.STUB)+ examples.code.role_playing.main(ModelType.STUB, chat_turn_limit=2)diff --git a/examples/test/test_role_description_example.py b/examples/test/test_role_description_example.pyindex f0eb5a9b3..9af5af894 100644--- a/examples/test/test_role_description_example.py+++ b/examples/test/test_role_description_example.py@@ -26,4 +26,4 @@ def test_role_generation_example():def test_role_playing_with_role_description_example():with patch('time.sleep', return_value=None):examples.role_description.role_playing_with_role_description.main(- ModelType.GPT_3_5_TURBO, ModelType.STUB)+ ModelType.GPT_3_5_TURBO, ModelType.STUB, chat_turn_limit=2)diff --git a/examples/translation/translator.py b/examples/translation/translator.pyindex faee1f2f0..6134c29f4 100644--- a/examples/translation/translator.py+++ b/examples/translation/translator.py@@ -92,7 +92,7 @@ def translate_content(args: argparse.Namespace, file_path: str,assistant_agent = ChatAgent(system_message=assistant_sys_msg,- model=ModelType.GPT_3_5_TURBO,+ model_type=ModelType.GPT_3_5_TURBO,model_config=model_config,)diff --git a/test/agents/test_babyagi_playing.py b/test/agents/test_babyagi_playing.pyindex f81d1d710..079fd0b40 100644--- a/test/agents/test_babyagi_playing.py+++ b/test/agents/test_babyagi_playing.py@@ -32,10 +32,10 @@ def test_babyagi_playing_init(model: ModelType):babyagi_playing = BabyAGI(assistant_role_name="Python Programmer",- assistant_agent_kwargs=dict(model=model),+ assistant_agent_kwargs=dict(model_type=model),user_role_name="Stock Trader",task_prompt=task_prompt,- task_specify_agent_kwargs=dict(model=model),+ task_specify_agent_kwargs=dict(model_type=model),message_window_size=5,)@@ -60,10 +60,10 @@ def test_babyagi_playing_step(model: ModelType):babyagi_playing = BabyAGI(assistant_role_name="Python Programmer",- assistant_agent_kwargs=dict(model=model),+ assistant_agent_kwargs=dict(model_type=model),user_role_name="Stock Trader",task_prompt=task_prompt,- task_specify_agent_kwargs=dict(model=model),+ task_specify_agent_kwargs=dict(model_type=model),message_window_size=5,)diff --git a/test/agents/test_chat_agent.py b/test/agents/test_chat_agent.pyindex 1060f152b..3d77e576d 100644--- a/test/agents/test_chat_agent.py+++ b/test/agents/test_chat_agent.py@@ -40,7 +40,8 @@ def test_chat_agent(model: ModelType):dict(assistant_role="doctor"),role_tuple=("doctor", RoleType.ASSISTANT),)- assistant = ChatAgent(system_msg, model=model, model_config=model_config)+ assistant = ChatAgent(system_msg, model_type=model,+ model_config=model_config)assert str(assistant) == ("ChatAgent(doctor, "f"RoleType.ASSISTANT, {str(model)})")@@ -86,7 +87,7 @@ def test_chat_agent_messages_window():content="You are a help assistant.")assistant = ChatAgent(system_message=system_msg,- model=ModelType.GPT_3_5_TURBO,+ model_type=ModelType.GPT_3_5_TURBO,message_window_size=2,)@@ -105,7 +106,7 @@ def test_chat_agent_step_exceed_token_number():role_type=RoleType.ASSISTANT, meta_dict=None,content="You are a help assistant.")assistant = ChatAgent(system_message=system_msg,- model=ModelType.GPT_3_5_TURBO, token_limit=1)+ model_type=ModelType.GPT_3_5_TURBO, token_limit=1)user_msg = BaseMessage(role_name="User", role_type=RoleType.USER,meta_dict=dict(), content="Tell me a joke.")@@ -178,7 +179,7 @@ def test_set_output_language():role_type=RoleType.ASSISTANT, meta_dict=None,content="You are a help assistant.")agent = ChatAgent(system_message=system_message,- model=ModelType.GPT_3_5_TURBO)+ model_type=ModelType.GPT_3_5_TURBO)assert agent.output_language is None# Set the output language to "Arabic"@@ -202,7 +203,7 @@ def test_set_multiple_output_language():role_type=RoleType.ASSISTANT, meta_dict=None,content="You are a help assistant.")agent = ChatAgent(system_message=system_message,- model=ModelType.GPT_3_5_TURBO)+ model_type=ModelType.GPT_3_5_TURBO)# Verify that the length of the system message is kept constant even when# multiple set_output_language operations are called@@ -222,7 +223,7 @@ def test_token_exceed_return():role_type=RoleType.ASSISTANT, meta_dict=None,content="You are a help assistant.")agent = ChatAgent(system_message=system_message,- model=ModelType.GPT_3_5_TURBO)+ model_type=ModelType.GPT_3_5_TURBO)expect_info = {"id": None,@@ -246,10 +247,11 @@ def test_function_enabled():model_config = FunctionCallingConfig(functions=[func.as_dict() for func in MATH_FUNCS])agent_no_func = ChatAgent(system_message=system_message,- model_config=model_config, model=ModelType.GPT_4)+ model_config=model_config,+ model_type=ModelType.GPT_4)agent_with_funcs = ChatAgent(system_message=system_message,model_config=model_config,- model=ModelType.GPT_4,+ model_type=ModelType.GPT_4,function_list=MATH_FUNCS)assert not agent_no_func.is_function_calling_enabled()@@ -264,7 +266,7 @@ def test_function_calling():model_config = FunctionCallingConfig(functions=[func.as_dict() for func in MATH_FUNCS])agent = ChatAgent(system_message=system_message, model_config=model_config,- model=ModelType.GPT_4, function_list=MATH_FUNCS)+ model_type=ModelType.GPT_4, function_list=MATH_FUNCS)ref_funcs = MATH_FUNCS@@ -297,7 +299,8 @@ def test_response_words_termination():response_terminator = ResponseWordsTerminator(words_dict=dict(goodbye=1))model_config = ChatGPTConfig(temperature=0, n=2)agent = ChatAgent(system_message=system_message,- model=ModelType.GPT_3_5_TURBO, model_config=model_config,+ model_type=ModelType.GPT_3_5_TURBO,+ model_config=model_config,response_terminators=[response_terminator])user_msg = BaseMessage(role_name="User", role_type=RoleType.USER,meta_dict=dict(),diff --git a/test/agents/test_role_assignment_agent.py b/test/agents/test_role_assignment_agent.pyindex e9b7e557c..7b116622a 100644--- a/test/agents/test_role_assignment_agent.py+++ b/test/agents/test_role_assignment_agent.py@@ -39,7 +39,7 @@ def test_role_assignment_agent(mock_step, model_type, num_roles):# Construct role assignment agentrole_description_agent = RoleAssignmentAgent(- model=model_type, model_config=model_config_description)+ model_type=model_type, model_config=model_config_description)# Generate the role description dictionary based on the mock step functionrole_description_dict = role_description_agent.run(task_prompt, num_roles)diff --git a/test/agents/test_role_playing.py b/test/agents/test_role_playing.pyindex cc9172e96..679a7cd89 100644--- a/test/agents/test_role_playing.py+++ b/test/agents/test_role_playing.py@@ -29,16 +29,16 @@ def test_role_playing_init(model_type, critic_role_name,with_critic_in_the_loop):role_playing = RolePlaying(assistant_role_name="assistant",- assistant_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO_16K),+ assistant_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO_16K),user_role_name="user",- user_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO_16K),+ user_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO_16K),model_type=model_type,critic_role_name=critic_role_name,task_prompt="Perform the task",with_task_specify=False,- task_specify_agent_kwargs=dict(model=ModelType.GPT_4),+ task_specify_agent_kwargs=dict(model_type=ModelType.GPT_4),with_task_planner=False,- task_planner_agent_kwargs=dict(model=ModelType.GPT_4),+ task_planner_agent_kwargs=dict(model_type=ModelType.GPT_4),with_critic_in_the_loop=with_critic_in_the_loop,task_type=TaskType.AI_SOCIETY,)@@ -62,11 +62,11 @@ def test_role_playing_init(model_type, critic_role_name,assert isinstance(assistant_agent, ChatAgent)assert isinstance(user_agent, ChatAgent)if model_type is None:- assert assistant_agent.model == ModelType.GPT_3_5_TURBO_16K- assert user_agent.model == ModelType.GPT_3_5_TURBO_16K+ assert assistant_agent.model_type == ModelType.GPT_3_5_TURBO_16K+ assert user_agent.model_type == ModelType.GPT_3_5_TURBO_16Kelse:- assert assistant_agent.model == ModelType.GPT_4- assert user_agent.model == ModelType.GPT_4+ assert assistant_agent.model_type == ModelType.GPT_4+ assert user_agent.model_type == ModelType.GPT_4if not with_critic_in_the_loop:assert critic is None@@ -78,9 +78,9 @@ def test_role_playing_init(model_type, critic_role_name,assert isinstance(critic, CriticAgent)assert role_playing.critic_sys_msg is not Noneif model_type is None:- assert critic.model == ModelType.GPT_3_5_TURBO+ assert critic.model_type == ModelType.GPT_3_5_TURBOelse:- assert critic.model == ModelType.GPT_4+ assert critic.model_type == ModelType.GPT_4@pytest.mark.model_backend@@ -94,11 +94,11 @@ def test_role_playing_step(task_type, extend_sys_msg_meta_dicts,extend_task_specify_meta_dict):role_playing = RolePlaying(assistant_role_name="AI Assistant",- assistant_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO),+ assistant_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO),user_role_name="AI User",- user_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO),+ user_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO),task_prompt="Perform the task",- task_specify_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO),+ task_specify_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO),task_type=task_type,extend_sys_msg_meta_dicts=extend_sys_msg_meta_dicts,extend_task_specify_meta_dict=extend_task_specify_meta_dict,@@ -127,13 +127,13 @@ def test_role_playing_with_function():role_playing = RolePlaying(assistant_role_name="AI Assistant",- assistant_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO,+ assistant_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO,model_config=assistant_model_config,function_list=function_list),user_role_name="AI User",- user_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO),+ user_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO),task_prompt="Perform the task",- task_specify_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO),+ task_specify_agent_kwargs=dict(model_type=ModelType.GPT_3_5_TURBO),task_type=TaskType.AI_SOCIETY,)@@ -152,12 +152,12 @@ def test_role_playing_role_sequence(model_type=None):task_prompt = "Develop a trading bot for the stock market"role_playing = RolePlaying(assistant_role_name="Python Programmer",- assistant_agent_kwargs=dict(model=model_type),+ assistant_agent_kwargs=dict(model_type=model_type),user_role_name="Stock Trader",- user_agent_kwargs=dict(model=model_type),+ user_agent_kwargs=dict(model_type=model_type),task_prompt=task_prompt,with_task_specify=True,- task_specify_agent_kwargs=dict(model=model_type),+ task_specify_agent_kwargs=dict(model_type=model_type),)assistant_role_sequence = []user_role_sequence = []@@ -172,7 +172,9 @@ def test_role_playing_role_sequence(model_type=None):for record in role_playing.assistant_agent.memory.get_context()[0]:assistant_role_sequence.append(record["role"])- assert user_role_sequence == \- ['system', 'user', 'assistant', 'user', 'assistant']- assert assistant_role_sequence == \- ['system', 'user', 'user', 'assistant', 'user', 'assistant']+ assert user_role_sequence == [+ 'system', 'user', 'assistant', 'user', 'assistant'+ ]+ assert assistant_role_sequence == [+ 'system', 'user', 'user', 'assistant', 'user', 'assistant'+ ]diff --git a/test/agents/test_task_agent.py b/test/agents/test_task_agent.pyindex de1f8dd83..caaa636d9 100644--- a/test/agents/test_task_agent.py+++ b/test/agents/test_task_agent.py@@ -35,7 +35,7 @@ def test_task_specify_ai_society_agent(model: Optional[ModelType]):original_task_prompt = "Improving stage presence and performance skills"print(f"Original task prompt:\n{original_task_prompt}\n")task_specify_agent = TaskSpecifyAgent(- model_config=ChatGPTConfig(temperature=1.0), model=model)+ model_config=ChatGPTConfig(temperature=1.0), model_type=model)specified_task_prompt = task_specify_agent.run(original_task_prompt, meta_dict=dict(assistant_role="Musician",user_role="Student"))@@ -50,7 +50,7 @@ def test_task_specify_code_agent(model: Optional[ModelType]):task_specify_agent = TaskSpecifyAgent(task_type=TaskType.CODE,model_config=ChatGPTConfig(temperature=1.0),- model=model,+ model_type=model,)specified_task_prompt = task_specify_agent.run(original_task_prompt, meta_dict=dict(domain="Chemistry",@@ -66,14 +66,14 @@ def test_task_planner_agent(model: Optional[ModelType]):task_specify_agent = TaskSpecifyAgent(task_type=TaskType.CODE,model_config=ChatGPTConfig(temperature=1.0),- model=model,+ model_type=model,)specified_task_prompt = task_specify_agent.run(original_task_prompt, meta_dict=dict(domain="Chemistry",language="Python"))print(f"Specified task prompt:\n{specified_task_prompt}\n")task_planner_agent = TaskPlannerAgent(- model_config=ChatGPTConfig(temperature=1.0), model=model)+ model_config=ChatGPTConfig(temperature=1.0), model_type=model)planned_task_prompt = task_planner_agent.run(specified_task_prompt)print(f"Planned task prompt:\n{planned_task_prompt}\n")@@ -83,7 +83,7 @@ def test_task_creation_agent(model: Optional[ModelType]):original_task_prompt = "Modeling molecular dynamics"task_creation_agent = TaskCreationAgent(role_name="PhD in molecular biology", objective=original_task_prompt,- model=model, model_config=ChatGPTConfig(temperature=1.0))+ model_type=model, model_config=ChatGPTConfig(temperature=1.0))task_list = ["Study the computational technology for dynamics modeling"]planned_task = task_creation_agent.run(task_list=task_list, )print(f"Planned task list:\n{planned_task}\n")@@ -107,7 +107,7 @@ def test_task_prioritization_agent(model: Optional[ModelType]):task_prioritization_agent = TaskPrioritizationAgent(model_config=ChatGPTConfig(temperature=1.0),- model=model,+ model_type=model,objective=original_task_prompt,)