🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
merge main
geekane6df55bdb9f6
diff --cc metagpt/roles/role.pyindex a20fe89e5,b234a846f..10b60d30e--- a/metagpt/roles/role.py+++ b/metagpt/roles/role.py@@@ -141,10 -151,24 +141,13 @@@ class Role(SerializationMixin, ContextM__hash__ = object.__hash__ # support Role as hashable type in `Environment.members`- @model_validator(mode="after")- def check_subscription(self):- if not self.subscription:- self.subscription = {any_to_str(self), self.name} if self.name else {any_to_str(self)}- return self-def __init__(self, **data: Any):- # --- avoid PydanticUndefinedAnnotation name 'Environment' is not defined #- from metagpt.environment import Environment-- Environment- # ------- Role.model_rebuild()+ self.pydantic_rebuild_model()super().__init__(**data)+ if self.is_human:+ self.llm = HumanProvider()+self.llm.system_prompt = self._get_prefix()self._watch(data.get("watch") or [UserRequirement])diff --cc tests/metagpt/utils/test_redis.pyindex 8e9cf710a,140c04f6b..5d6eb1042--- a/tests/metagpt/utils/test_redis.py+++ b/tests/metagpt/utils/test_redis.py@@@ -5,11 -5,11 +5,12 @@@@Author : mashenquan@File : test_redis.py"""+ from unittest.mock import AsyncMock- import mockimport pytest++from pytest_mock import mocker-from metagpt.config import CONFIG+from metagpt.config2 import Configfrom metagpt.utils.redis import Redis@@@ -21,11 -21,18 +22,11 @@@ async def async_mock_from_url(*args, **@pytest.mark.asyncio- @mock.patch("aioredis.from_url", return_value=async_mock_from_url())-async def test_redis(mocker):- # Mock+async def test_redis(i):+ redis = Config.default().redis+ mocker.patch("aioredis.from_url", return_value=async_mock_from_url())- # Prerequisites- CONFIG.REDIS_HOST = "MOCK_REDIS_HOST"- CONFIG.REDIS_PORT = "MOCK_REDIS_PORT"- CONFIG.REDIS_PASSWORD = "MOCK_REDIS_PASSWORD"- CONFIG.REDIS_DB = 0-- conn = Redis()- assert not conn.is_valid+ conn = Redis(redis)await conn.set("test", "test", timeout_sec=0)assert await conn.get("test") == b"test"await conn.close()