Skip to content

Commit

Permalink
fixbug: unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
莘权 马 committed Aug 7, 2024
1 parent f39658d commit 945c24a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions metagpt/actions/design_api_an.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,7 +45,7 @@
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],
Expand Down
4 changes: 2 additions & 2 deletions metagpt/utils/make_sk_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/metagpt/serialize_deserialize/test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

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()])
Expand Down
6 changes: 3 additions & 3 deletions tests/metagpt/serialize_deserialize/test_serdeser_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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
Expand Down Expand Up @@ -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):
Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions tests/metagpt/serialize_deserialize/test_sk_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
4 changes: 4 additions & 0 deletions tests/metagpt/serialize_deserialize/test_write_code_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

0 comments on commit 945c24a

Please sign in to comment.