Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

refactor: rename async_put_message to put_message

莘权 马bc1a757293b0
diff --git a/metagpt/environment.py b/metagpt/environment.py
index ba0645a36..7ba077080 100644
--- a/metagpt/environment.py
+++ b/metagpt/environment.py
@@ -50,7 +50,7 @@ class Environment(BaseModel):
found = False
for r in self.roles.values():
if message.is_recipient(r.subscribed_tags):
- r.async_put_message(message)
+ r.put_message(message)
found = True
if not found:
logger.warning(f"Message no recipients: {message.save()}")
diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py
index 0a6716428..6fba40bd8 100644
--- a/metagpt/roles/role.py
+++ b/metagpt/roles/role.py
@@ -11,10 +11,10 @@
they've subscribed to through the `subscribed_tags` property.
3. Move the message receive buffer from the global variable `self._rc.env.memory` to the role's private variable
`self._rc.msg_buffer` for easier message identification and asynchronous appending of messages.
- 4. Standardize the way messages are passed: `publish_message` sends messages out, while `async_put_message` places
+ 4. Standardize the way messages are passed: `publish_message` sends messages out, while `put_message` places
messages into the Role object's private message receive buffer. There are no other message transmit methods.
5. Standardize the parameters for the `run` function: the `test_message` parameter is used for testing purposes
- only. In the normal workflow, you should use `publish_message` or `async_put_message` to transmit messages.
+ only. In the normal workflow, you should use `publish_message` or `put_message` to transmit messages.
"""
from __future__ import annotations
@@ -239,7 +239,7 @@ class Role(Named):
return
self._rc.env.publish_message(msg)
- def async_put_message(self, message):
+ def put_message(self, message):
"""Place the message into the Role object's private message buffer."""
if not message:
return
@@ -261,7 +261,7 @@ class Role(Named):
seed = test_message
elif isinstance(test_message, list):
seed = Message("\n".join(test_message))
- self.async_put_message(seed)
+ self.put_message(seed)
if not await self._observe():
# If there is no new information, suspend and wait
diff --git a/tests/metagpt/planner/test_action_planner.py b/tests/metagpt/planner/test_action_planner.py
index a3831c08d..99cc25b72 100644
--- a/tests/metagpt/planner/test_action_planner.py
+++ b/tests/metagpt/planner/test_action_planner.py
@@ -26,7 +26,7 @@ async def test_action_planner():
role.import_skill(TimeSkill(), "time")
role.import_skill(TextSkill(), "text")
task = "What is the sum of 110 and 990?"
- role.async_put_message(Message(content=task, cause_by=BossRequirement.get_class_name()))
+ role.put_message(Message(content=task, cause_by=BossRequirement.get_class_name()))
await role._observe()
await role._think() # it will choose mathskill.Add
assert "1100" == (await role._act()).content
diff --git a/tests/metagpt/planner/test_basic_planner.py b/tests/metagpt/planner/test_basic_planner.py
index 9efcb9367..fa7ed7074 100644
--- a/tests/metagpt/planner/test_basic_planner.py
+++ b/tests/metagpt/planner/test_basic_planner.py
@@ -29,7 +29,7 @@ async def test_basic_planner():
role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "WriterSkill")
role.import_skill(TextSkill(), "TextSkill")
# using BasicPlanner
- role.async_put_message(Message(content=task, cause_by=BossRequirement.get_class_name()))
+ role.put_message(Message(content=task, cause_by=BossRequirement.get_class_name()))
await role._observe()
await role._think()
# assuming sk_agent will think he needs WriterSkill.Brainstorm and WriterSkill.Translate
diff --git a/tests/metagpt/roles/test_architect.py b/tests/metagpt/roles/test_architect.py
index 910c589ca..665242379 100644
--- a/tests/metagpt/roles/test_architect.py
+++ b/tests/metagpt/roles/test_architect.py
@@ -16,7 +16,7 @@ from tests.metagpt.roles.mock import MockMessages
@pytest.mark.asyncio
async def test_architect():
role = Architect()
- role.async_put_message(MockMessages.req)
+ role.put_message(MockMessages.req)
rsp = await role.run(MockMessages.prd)
logger.info(rsp)
assert len(rsp.content) > 0
diff --git a/tests/metagpt/roles/test_engineer.py b/tests/metagpt/roles/test_engineer.py
index e80234b3b..93c3132ac 100644
--- a/tests/metagpt/roles/test_engineer.py
+++ b/tests/metagpt/roles/test_engineer.py
@@ -23,9 +23,9 @@ from tests.metagpt.roles.mock import (
async def test_engineer():
engineer = Engineer()
- engineer.async_put_message(MockMessages.req)
- engineer.async_put_message(MockMessages.prd)
- engineer.async_put_message(MockMessages.system_design)
+ engineer.put_message(MockMessages.req)
+ engineer.put_message(MockMessages.prd)
+ engineer.put_message(MockMessages.system_design)
rsp = await engineer.run(MockMessages.tasks)
logger.info(rsp)