Skip to content

Commit

Permalink
feat: +git import
Browse files Browse the repository at this point in the history
  • Loading branch information
莘权 马 committed Apr 1, 2024
1 parent b70ed4c commit 66b6839
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
7 changes: 7 additions & 0 deletions metagpt/actions/intent_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ class SOPItem(BaseModel):
"Stage and commit changes for the project repository using Git.",
],
),
SOPItem(
description="download repository from git and format the project to MetaGPT project",
sop=[
"Imports a project from a Git website and formats it to MetaGPT project format to enable incremental appending requirements.",
"Stage and commit changes for the project repository using Git.",
],
),
]


Expand Down
8 changes: 6 additions & 2 deletions tests/metagpt/actions/test_intent_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@
{"role": "user", "content": "TypeError: __init__() takes 1 positional argument but 2 were given"},
]

DEMO3_CONTENT = [
{"role": "user", "content": "git clone 'https://github.com/spec-first/connexion' and format to MetaGPT project"}
]


@pytest.mark.asyncio
@pytest.mark.parametrize(
"content",
[json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT)],
[json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT), json.dumps(DEMO3_CONTENT)],
)
async def test_intent_detect(content: str, context):
action = IntentDetect(context=context)
Expand All @@ -151,7 +155,7 @@ async def test_intent_detect(content: str, context):
@pytest.mark.asyncio
@pytest.mark.parametrize(
"content",
[json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT)],
[json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT), json.dumps(DEMO3_CONTENT)],
)
async def test_light_intent_detect(content: str, context):
action = LightIntentDetect(context=context)
Expand Down
19 changes: 12 additions & 7 deletions tests/metagpt/roles/di/test_mgx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import pytest

from metagpt.context import Context
from metagpt.roles.di.mgx import MGX
from metagpt.schema import Message
from tests.metagpt.actions.test_intent_detect import (
DEMO1_CONTENT,
DEMO2_CONTENT,
DEMO3_CONTENT,
DEMO_CONTENT,
)

Expand All @@ -23,10 +23,9 @@
[Message.model_validate(i) for i in DEMO1_CONTENT if i["role"] == "user"],
],
)
# @pytest.mark.skip
@pytest.mark.skip
async def test_mgx(user_messages: List[Message], context):
ctx = context
mgx = MGX(context=ctx, tools=["<all>"])
mgx = MGX(context=context, tools=["<all>"])

for i, msg in enumerate(user_messages):
await mgx.run(msg)
Expand All @@ -39,15 +38,21 @@ async def test_mgx(user_messages: List[Message], context):
("user_message", "history_messages"),
[(Message.model_validate(DEMO2_CONTENT[2]), [Message.model_validate(i) for i in DEMO2_CONTENT[0:2]])],
)
# @pytest.mark.skip
@pytest.mark.skip
async def test_mgx_fixbug(user_message: Message, history_messages: List[Message], context):
ctx = Context()
mgx = MGX(context=ctx, tools=["<all>"])
mgx = MGX(context=context, tools=["<all>"])
mgx.rc.memory.add_batch(history_messages)
await mgx.run(user_message)
data = mgx.model_dump_json()
await context.repo.test_outputs.save(filename="test_mgx_fixbug.json", content=data)


@pytest.mark.asyncio
@pytest.mark.parametrize("user_message", [Message.model_validate(i) for i in DEMO3_CONTENT if i.role == "user"])
async def test_git_import(user_message, context):
mgx = MGX(context=context, tools=["<all>"])
await mgx.run(user_message)


if __name__ == "__main__":
pytest.main([__file__, "-s"])

0 comments on commit 66b6839

Please sign in to comment.