mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
fixbug: unit test
This commit is contained in:
parent
f39658db2b
commit
945c24ae15
6 changed files with 17 additions and 9 deletions
|
|
@ -5,7 +5,7 @@
|
|||
@Author : alexanderwu
|
||||
@File : design_api_an.py
|
||||
"""
|
||||
from typing import List,Optional
|
||||
from typing import List, Optional
|
||||
|
||||
from metagpt.actions.action_node import ActionNode
|
||||
from metagpt.utils.mermaid import MMC1, MMC2
|
||||
|
|
@ -45,7 +45,7 @@ REFINED_FILE_LIST = ActionNode(
|
|||
example=["main.py", "game.py", "new_feature.py"],
|
||||
)
|
||||
|
||||
#optional,because low success reproduction of class diagram in non py project.
|
||||
# optional,because low success reproduction of class diagram in non py project.
|
||||
DATA_STRUCTURES_AND_INTERFACES = ActionNode(
|
||||
key="Data structures and interfaces",
|
||||
expected_type=Optional[str],
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ def make_sk_kernel():
|
|||
if llm := config.get_azure_llm():
|
||||
kernel.add_chat_service(
|
||||
"chat_completion",
|
||||
AzureChatCompletion(llm.model, llm.base_url, llm.api_key),
|
||||
AzureChatCompletion(deployment_name=llm.model, base_url=llm.base_url, api_key=llm.api_key),
|
||||
)
|
||||
elif llm := config.get_openai_llm():
|
||||
kernel.add_chat_service(
|
||||
"chat_completion",
|
||||
OpenAIChatCompletion(llm.model, llm.api_key),
|
||||
OpenAIChatCompletion(ai_model_id=llm.model, api_key=llm.api_key),
|
||||
)
|
||||
|
||||
return kernel
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ from tests.metagpt.serialize_deserialize.test_serdeser_base import (
|
|||
|
||||
def test_roles(context):
|
||||
role_a = RoleA()
|
||||
assert len(role_a.rc.watch) == 1
|
||||
assert len(role_a.rc.watch) == 2
|
||||
role_b = RoleB()
|
||||
assert len(role_a.rc.watch) == 1
|
||||
assert len(role_a.rc.watch) == 2
|
||||
assert len(role_b.rc.watch) == 1
|
||||
|
||||
role_d = RoleD(actions=[ActionOK()])
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from typing import Optional
|
|||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from metagpt.actions import Action, ActionOutput
|
||||
from metagpt.actions import Action, ActionOutput, UserRequirement
|
||||
from metagpt.actions.action_node import ActionNode
|
||||
from metagpt.actions.fix_bug import FixBug
|
||||
from metagpt.roles.role import Role, RoleReactMode
|
||||
|
|
@ -68,7 +68,7 @@ class RoleA(Role):
|
|||
def __init__(self, **kwargs):
|
||||
super(RoleA, self).__init__(**kwargs)
|
||||
self.set_actions([ActionPass])
|
||||
self._watch([FixBug])
|
||||
self._watch([FixBug, UserRequirement])
|
||||
|
||||
|
||||
class RoleB(Role):
|
||||
|
|
@ -93,7 +93,7 @@ class RoleC(Role):
|
|||
def __init__(self, **kwargs):
|
||||
super(RoleC, self).__init__(**kwargs)
|
||||
self.set_actions([ActionOK, ActionRaise])
|
||||
self._watch([FixBug])
|
||||
self._watch([FixBug, UserRequirement])
|
||||
self.rc.react_mode = RoleReactMode.BY_ORDER
|
||||
self.rc.memory.ignore_id = True
|
||||
|
||||
|
|
|
|||
|
|
@ -15,3 +15,7 @@ async def test_sk_agent_serdeser():
|
|||
new_role = SkAgent(**ser_role_dict)
|
||||
assert new_role.name == "Sunshine"
|
||||
assert len(new_role.actions) == 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-s"])
|
||||
|
|
|
|||
|
|
@ -29,3 +29,7 @@ def div(a: int, b: int = 0):
|
|||
|
||||
assert new_action.name == "WriteCodeReview"
|
||||
await new_action.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-s"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue