Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

fix: output_language setting in ChatAgent (#1165)

Wendong-Fan32f19f59f4ff
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 26c25a0d8..3c08d8b21 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -26,7 +26,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
- placeholder: E.g., 0.2.6
+ placeholder: E.g., 0.2.7
validations:
required: true
diff --git a/README.md b/README.md
index f1f12720d..8a60ceff2 100644
--- a/README.md
+++ b/README.md
@@ -144,7 +144,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
-git clone -b v0.2.6 https://github.com/camel-ai/camel.git
+git clone -b v0.2.7 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
diff --git a/camel/__init__.py b/camel/__init__.py
index da74eb223..9f5ed3a4a 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -12,7 +12,7 @@
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
-__version__ = '0.2.6'
+__version__ = '0.2.7'
__all__ = [
'__version__',
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.py
index 1c5f9a2c4..fb1d79c4a 100644
--- a/camel/agents/chat_agent.py
+++ b/camel/agents/chat_agent.py
@@ -180,9 +180,6 @@ class ChatAgent(BaseAgent):
model_type=ModelType.DEFAULT,
)
)
- self.output_language: Optional[str] = output_language
- if self.output_language is not None:
- self.set_output_language(self.output_language)
self.model_type = self.model_backend.model_type
@@ -218,6 +215,10 @@ class ChatAgent(BaseAgent):
context_creator, window_size=message_window_size
)
+ self.output_language: Optional[str] = output_language
+ if self.output_language is not None:
+ self.set_output_language(self.output_language)
+
self.terminated: bool = False
self.response_terminators = response_terminators or []
self.init_messages()
@@ -371,13 +372,19 @@ class ChatAgent(BaseAgent):
self._system_message = self.orig_sys_message.create_new_instance(
content
)
- return self._system_message
else:
self._system_message = BaseMessage.make_assistant_message(
role_name="Assistant",
content=language_prompt,
)
- return self._system_message
+
+ system_record = MemoryRecord(
+ message=self._system_message,
+ role_at_backend=OpenAIBackendRole.SYSTEM,
+ )
+ self.memory.clear()
+ self.memory.write_record(system_record)
+ return self._system_message
def get_info(
self,
diff --git a/docs/conf.py b/docs/conf.py
index d8d027bb8..08d34f2c3 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
-release = '0.2.6'
+release = '0.2.7'
html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
diff --git a/docs/cookbooks/agents_message.ipynb b/docs/cookbooks/agents_message.ipynb
index ed4800c7b..58d523aec 100644
--- a/docs/cookbooks/agents_message.ipynb
+++ b/docs/cookbooks/agents_message.ipynb
@@ -101,7 +101,7 @@
},
"outputs": [],
"source": [
- "!pip install \"camel-ai==0.2.6\""
+ "!pip install \"camel-ai==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/agents_prompting.ipynb b/docs/cookbooks/agents_prompting.ipynb
index 7e393b220..448a2f643 100644
--- a/docs/cookbooks/agents_prompting.ipynb
+++ b/docs/cookbooks/agents_prompting.ipynb
@@ -64,7 +64,7 @@
},
"outputs": [],
"source": [
- "!pip install \"camel-ai==0.2.6\""
+ "!pip install \"camel-ai==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/agents_society.ipynb b/docs/cookbooks/agents_society.ipynb
index a7bac22e6..5342791a7 100644
--- a/docs/cookbooks/agents_society.ipynb
+++ b/docs/cookbooks/agents_society.ipynb
@@ -192,7 +192,7 @@
},
"outputs": [],
"source": [
- "!pip install \"camel-ai==0.2.6\""
+ "!pip install \"camel-ai==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/agents_tracking.ipynb b/docs/cookbooks/agents_tracking.ipynb
index a2522bf33..61a9f0dc7 100644
--- a/docs/cookbooks/agents_tracking.ipynb
+++ b/docs/cookbooks/agents_tracking.ipynb
@@ -64,7 +64,7 @@
},
"outputs": [],
"source": [
- "%pip install camel-ai[all]==0.2.6\n",
+ "%pip install camel-ai[all]==0.2.7\n",
"%pip install agentops==0.3.10"
]
},
diff --git a/docs/cookbooks/agents_with_memory.ipynb b/docs/cookbooks/agents_with_memory.ipynb
index 334bbf9fd..3ef3e1b8a 100644
--- a/docs/cookbooks/agents_with_memory.ipynb
+++ b/docs/cookbooks/agents_with_memory.ipynb
@@ -73,7 +73,7 @@
},
"outputs": [],
"source": [
- "!pip install \"camel-ai[all]==0.2.6\""
+ "!pip install \"camel-ai[all]==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/agents_with_rag.ipynb b/docs/cookbooks/agents_with_rag.ipynb
index d0d5c4ad4..9894ebd16 100644
--- a/docs/cookbooks/agents_with_rag.ipynb
+++ b/docs/cookbooks/agents_with_rag.ipynb
@@ -75,7 +75,7 @@
},
"outputs": [],
"source": [
- "!pip install \"camel-ai[all]==0.2.6\""
+ "!pip install \"camel-ai[all]==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/agents_with_tools.ipynb b/docs/cookbooks/agents_with_tools.ipynb
index eae19ddb4..d21df02c6 100644
--- a/docs/cookbooks/agents_with_tools.ipynb
+++ b/docs/cookbooks/agents_with_tools.ipynb
@@ -77,7 +77,7 @@
},
"outputs": [],
"source": [
- "!pip install \"camel-ai[all]==0.2.6\""
+ "!pip install \"camel-ai[all]==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/create_your_first_agent.ipynb b/docs/cookbooks/create_your_first_agent.ipynb
index 3eb0977c2..b5577974c 100644
--- a/docs/cookbooks/create_your_first_agent.ipynb
+++ b/docs/cookbooks/create_your_first_agent.ipynb
@@ -83,7 +83,7 @@
{
"cell_type": "code",
"source": [
- "!pip install \"camel-ai[all]==0.2.6\""
+ "!pip install \"camel-ai[all]==0.2.7\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
diff --git a/docs/cookbooks/create_your_first_agents_society.ipynb b/docs/cookbooks/create_your_first_agents_society.ipynb
index c9cf04204..7c8704e4e 100644
--- a/docs/cookbooks/create_your_first_agents_society.ipynb
+++ b/docs/cookbooks/create_your_first_agents_society.ipynb
@@ -77,7 +77,7 @@
{
"cell_type": "code",
"source": [
- "!pip install \"camel-ai==0.2.6\""
+ "!pip install \"camel-ai==0.2.7\""
],
"metadata": {
"id": "RiwfwyyLYYxo"
diff --git a/docs/cookbooks/critic_agents_and_tree_search.ipynb b/docs/cookbooks/critic_agents_and_tree_search.ipynb
index 678012455..ec7289ead 100644
--- a/docs/cookbooks/critic_agents_and_tree_search.ipynb
+++ b/docs/cookbooks/critic_agents_and_tree_search.ipynb
@@ -84,7 +84,7 @@
{
"cell_type": "code",
"source": [
- "%pip install \"camel-ai==0.2.6\""
+ "%pip install \"camel-ai==0.2.7\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
diff --git a/docs/cookbooks/embodied_agents.ipynb b/docs/cookbooks/embodied_agents.ipynb
index 4c5eb710b..1b861ee39 100644
--- a/docs/cookbooks/embodied_agents.ipynb
+++ b/docs/cookbooks/embodied_agents.ipynb
@@ -67,7 +67,7 @@
{
"cell_type": "code",
"source": [
- "%pip install \"camel-ai==0.2.6\""
+ "%pip install \"camel-ai==0.2.7\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
diff --git a/docs/cookbooks/knowledge_graph.ipynb b/docs/cookbooks/knowledge_graph.ipynb
index 0aa8510a4..90995ab75 100644
--- a/docs/cookbooks/knowledge_graph.ipynb
+++ b/docs/cookbooks/knowledge_graph.ipynb
@@ -73,7 +73,7 @@
},
"outputs": [],
"source": [
- "pip install \"camel-ai[all]==0.2.6\""
+ "pip install \"camel-ai[all]==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/model_speed_comparison.ipynb b/docs/cookbooks/model_speed_comparison.ipynb
index 06acc253b..81f81f351 100644
--- a/docs/cookbooks/model_speed_comparison.ipynb
+++ b/docs/cookbooks/model_speed_comparison.ipynb
@@ -63,7 +63,7 @@
{
"cell_type": "code",
"source": [
- "!pip install \"camel-ai==0.2.6\""
+ "!pip install \"camel-ai==0.2.7\""
],
"metadata": {
"id": "UtcC3c-KVZmU"
diff --git a/docs/cookbooks/roleplaying_scraper.ipynb b/docs/cookbooks/roleplaying_scraper.ipynb
index ce7feb469..2819deda5 100644
--- a/docs/cookbooks/roleplaying_scraper.ipynb
+++ b/docs/cookbooks/roleplaying_scraper.ipynb
@@ -89,7 +89,7 @@
},
"outputs": [],
"source": [
- "!pip install \"camel-ai[all]==0.2.6\""
+ "!pip install \"camel-ai[all]==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/task_generation.ipynb b/docs/cookbooks/task_generation.ipynb
index ab00c67b3..be51664f7 100644
--- a/docs/cookbooks/task_generation.ipynb
+++ b/docs/cookbooks/task_generation.ipynb
@@ -62,7 +62,7 @@
},
"outputs": [],
"source": [
- "!pip install \"camel-ai==0.2.6\""
+ "!pip install \"camel-ai==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/video_analysis.ipynb b/docs/cookbooks/video_analysis.ipynb
index b028581cc..7f5de0eab 100644
--- a/docs/cookbooks/video_analysis.ipynb
+++ b/docs/cookbooks/video_analysis.ipynb
@@ -28,7 +28,7 @@
},
"outputs": [],
"source": [
- "%pip install \"camel-ai[all]==0.2.6\""
+ "%pip install \"camel-ai[all]==0.2.7\""
]
},
{
diff --git a/docs/cookbooks/workforce_judge_committee.ipynb b/docs/cookbooks/workforce_judge_committee.ipynb
index f8471a40a..0ef349742 100644
--- a/docs/cookbooks/workforce_judge_committee.ipynb
+++ b/docs/cookbooks/workforce_judge_committee.ipynb
@@ -28,7 +28,7 @@
},
"outputs": [],
"source": [
- "%pip install \"camel-ai[all]==0.2.6\""
+ "%pip install \"camel-ai[all]==0.2.7\""
]
},
{
diff --git a/docs/get_started/installation.md b/docs/get_started/installation.md
index 495907b2f..57aa1e64a 100644
--- a/docs/get_started/installation.md
+++ b/docs/get_started/installation.md
@@ -60,7 +60,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
-git clone -b v0.2.6 https://github.com/camel-ai/camel.git
+git clone -b v0.2.7 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
diff --git a/docs/key_modules/loaders.md b/docs/key_modules/loaders.md
index ee5b13fba..5818aba93 100644
--- a/docs/key_modules/loaders.md
+++ b/docs/key_modules/loaders.md
@@ -336,14 +336,14 @@ response = jina_reader.read_content("https://docs.camel-ai.org/")
print(response)
```
```markdown
->>>Welcome to CAMEL’s documentation! — CAMEL 0.2.6 documentation
+>>>Welcome to CAMEL’s documentation! — CAMEL 0.2.7 documentation
===============
[Skip to main content](https://docs.camel-ai.org/#main-content)
Back to top Ctrl+K
- [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.6](https://docs.camel-ai.org/#)
+ [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.7](https://docs.camel-ai.org/#)
Search Ctrl+K
diff --git a/pyproject.toml b/pyproject.toml
index 6e49331e7..17506ed08 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "camel-ai"
-version = "0.2.6"
+version = "0.2.7"
authors = ["CAMEL-AI.org"]
description = "Communicative Agents for AI Society Study"
readme = "README.md"
diff --git a/test/agents/test_chat_agent.py b/test/agents/test_chat_agent.py
index ba28ec314..290c5bc46 100644
--- a/test/agents/test_chat_agent.py
+++ b/test/agents/test_chat_agent.py
@@ -414,14 +414,13 @@ def test_set_output_language():
assert agent.output_language == output_language
# Verify that the system message is updated with the new output language
- 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 Arabic.",
- )
- assert agent.system_message.content == updated_system_message.content
+ updated_system_message = {
+ 'role': 'system',
+ 'content': 'You are a help assistant.\nRegardless of the '
+ 'input language, you must output text in Arabic.',
+ }
+ memory_content = agent.memory.get_context()
+ assert memory_content[0][0] == updated_system_message
@pytest.mark.model_backend
@@ -444,28 +443,27 @@ def test_set_multiple_output_language():
agent_without_sys_msg.set_output_language("English")
agent_without_sys_msg.set_output_language("French")
- updated_system_message_with_content = 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.",
- )
- updated_system_message_without_content = BaseMessage(
- role_name="assistant",
- role_type=RoleType.ASSISTANT,
- meta_dict=None,
- content="\nRegardless of the input language, you must output text "
- "in French.",
- )
+ updated_system_message_with_sys_msg = {
+ 'role': 'system',
+ 'content': 'You are a help assistant.\nRegardless of the '
+ 'input language, you must output text in French.',
+ }
+ updated_system_message_without_sys_msg = {
+ 'role': 'system',
+ 'content': '\nRegardless of the input language, you must output '
+ 'text in French.',
+ }
+
+ memory_content_with_sys_msg = agent_with_sys_msg.memory.get_context()
+ memory_content_without_sys_msg = agent_without_sys_msg.memory.get_context()
assert (
- agent_with_sys_msg.system_message.content
- == updated_system_message_with_content.content
+ memory_content_with_sys_msg[0][0]
+ == updated_system_message_with_sys_msg
)
assert (
- agent_without_sys_msg.system_message.content
- == updated_system_message_without_content.content
+ memory_content_without_sys_msg[0][0]
+ == updated_system_message_without_sys_msg
)