Merge pull request #717 from kkdev163/fixbug/role_init_human_provider

fixbug: role init with is_human=True was not work
This commit is contained in:
garylin2099 2024-01-09 12:43:26 +08:00 committed by GitHub
commit 16e3f94b44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -166,6 +166,9 @@ class Role(SerializationMixin, is_polymorphic_base=True):
Role.model_rebuild()
super().__init__(**data)
if self.is_human:
self.llm = HumanProvider()
self.llm.system_prompt = self._get_prefix()
self._watch(data.get("watch") or [UserRequirement])

View file

@ -3,6 +3,7 @@
# @Desc : unittest of Role
import pytest
from metagpt.llm import HumanProvider
from metagpt.roles.role import Role
@ -12,5 +13,10 @@ def test_role_desc():
assert role.desc == "Best Seller"
def test_role_human():
role = Role(is_human=True)
assert isinstance(role.llm, HumanProvider)
if __name__ == "__main__":
pytest.main([__file__, "-s"])