🐫 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
Fix set_output_language (#223)
MorphlingEd7a09b3676186
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.pyindex 93863e5b0..2f7f2184f 100644--- a/camel/agents/chat_agent.py+++ b/camel/agents/chat_agent.py@@ -103,6 +103,7 @@ class ChatAgent(BaseAgent):output_language: Optional[str] = None,) -> None:+ self.orig_sys_message: BaseMessage = system_messageself.system_message: BaseMessage = system_messageself.role_name: str = system_message.role_nameself.role_type: RoleType = system_message.role_type@@ -146,7 +147,7 @@ class ChatAgent(BaseAgent):BaseMessage: The updated system message object."""self.output_language = output_language- content = (self.system_message.content ++ content = (self.orig_sys_message.content +("\nRegardless of the input language, "f"you must output text in {output_language}."))self.system_message = self.system_message.create_new_instance(content)diff --git a/test/agents/test_chat_agent.py b/test/agents/test_chat_agent.pyindex 2e278f2f5..a99a5460d 100644--- a/test/agents/test_chat_agent.py+++ b/test/agents/test_chat_agent.py@@ -126,3 +126,14 @@ def test_set_output_language():content="You are a help assistant.""\nRegardless of the input language, you must output text in Arabic.")assert agent.system_message.content == updated_system_message.content++ # Verify that the length of the system message is kept constant even when+ # multiple set_output_language operations are called+ agent.set_output_language("Chinese")+ agent.set_output_language("English")+ agent.set_output_language("French")+ updated_system_message = BaseMessage(+ role_name="assistant", role_type=RoleType.ASSISTANT, meta_dict=None,+ content="You are a help assistant."+ "\nRegardless of the input language, you must output text in French.")+ assert agent.system_message.content == updated_system_message.content