mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
refactor: rename async_put_message to put_message
This commit is contained in:
parent
bfaeda0a90
commit
bc1a757293
6 changed files with 11 additions and 11 deletions
|
|
@ -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()}")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue