🐫 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
Replaced asserts with exceptions in the package (#81)
Dmitrii Khizbullinba3ec7603ebc
diff --git a/camel/agents/task_agent.py b/camel/agents/task_agent.pyindex f7a865b06..7482ed590 100644--- a/camel/agents/task_agent.py+++ b/camel/agents/task_agent.py@@ -22,7 +22,9 @@ class TaskSpecifyAgent(ChatAgent):if task_specify_prompt is None:prompt_template = PromptTemplate.get_task_specify_prompt(task_type)task_specify_prompt = prompt_template.template- assert "<WORD_LIMIT>" in prompt_template.key_words+ if "<WORD_LIMIT>" not in prompt_template.key_words:+ raise ValueError("Prompt template does not contain "+ "a word limit placeholder")self.task_specify_prompt = task_specify_prompt.replace("<WORD_LIMIT>", str(word_limit))@@ -52,7 +54,9 @@ class TaskSpecifyAgent(ChatAgent):for replace_tuple in replace_tuples:self.task_specify_prompt = self.task_specify_prompt.replace(replace_tuple[0], replace_tuple[1])- assert "<" and ">" not in self.task_specify_prompt+ if not ("<" and ">" not in self.task_specify_prompt):+ raise ValueError("Task specifier prompt must "+ "have no angle brackets")task_msg = UserChatMessage(role_name="Task Specifier",content=self.task_specify_prompt)specified_task_msgs, terminated, _ = self.step(task_msg)diff --git a/camel/messages.py b/camel/messages.pyindex a1a68d2ba..51b9ef35e 100644--- a/camel/messages.py+++ b/camel/messages.py@@ -20,7 +20,8 @@ class BaseMessage:def to_openai_message(self, role: Optional[str] = None) -> OpenAIMessage:role = role or self.role- assert role in ["system", "user", "assistant"]+ if role not in {"system", "user", "assistant"}:+ raise ValueError(f"Unrecognized role: {role}")return {"role": role, "content": self.content}def to_openai_chat_message(@@ -28,7 +29,8 @@ class BaseMessage:role: Optional[str] = None,) -> OpenAIChatMessage:role = role or self.role- assert role in ["user", "assistant"]+ if role not in {"user", "assistant"}:+ raise ValueError(f"Unrecognized role: {role}")return {"role": role, "content": self.content}def to_openai_system_message(self) -> OpenAISystemMessage: