From de53a1ae3563704e9c8a09eaab551f82b8fcb4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Mon, 1 Apr 2024 19:44:00 +0800 Subject: [PATCH] fixbug: fixbug intent --- metagpt/actions/intent_detect.py | 9 ++++++++- tests/metagpt/actions/test_intent_detect.py | 10 ++++++++-- tests/metagpt/roles/di/test_mgx.py | 11 ++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/metagpt/actions/intent_detect.py b/metagpt/actions/intent_detect.py index 052547798..a520763cd 100644 --- a/metagpt/actions/intent_detect.py +++ b/metagpt/actions/intent_detect.py @@ -47,7 +47,14 @@ SOP_CONFIG = [ # "Run QA test on the project repository.", "Stage and commit changes for the project repository using Git.", ], - ) + ), + SOPItem( + description="Error message, issues, fix bug", + sop=[ + "Fix bugs in the project repository.", + "Stage and commit changes for the project repository using Git.", + ], + ), ] diff --git a/tests/metagpt/actions/test_intent_detect.py b/tests/metagpt/actions/test_intent_detect.py index 95efc16d8..1a7acd3e7 100644 --- a/tests/metagpt/actions/test_intent_detect.py +++ b/tests/metagpt/actions/test_intent_detect.py @@ -42,11 +42,17 @@ DEMO1_CONTENT = [ } ] +DEMO2_CONTENT = [ + {"role": "user", "content": 'Create a "2048 game"'}, + {"role": "assistant", "content": ""}, + {"role": "user", "content": "TypeError: __init__() takes 1 positional argument but 2 were given"}, +] + @pytest.mark.asyncio @pytest.mark.parametrize( "content", - [json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT)], + [json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT)], ) async def test_intent_detect(content: str, context): action = IntentDetect(context=context) @@ -63,7 +69,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(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT)], ) async def test_light_intent_detect(content: str, context): action = LightIntentDetect(context=context) diff --git a/tests/metagpt/roles/di/test_mgx.py b/tests/metagpt/roles/di/test_mgx.py index 2ff886d3d..2aca45867 100644 --- a/tests/metagpt/roles/di/test_mgx.py +++ b/tests/metagpt/roles/di/test_mgx.py @@ -7,7 +7,11 @@ 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, DEMO_CONTENT +from tests.metagpt.actions.test_intent_detect import ( + DEMO1_CONTENT, + DEMO2_CONTENT, + DEMO_CONTENT, +) @pytest.mark.asyncio @@ -16,10 +20,7 @@ from tests.metagpt.actions.test_intent_detect import DEMO1_CONTENT, DEMO_CONTENT [ [Message.model_validate(i) for i in DEMO_CONTENT if i["role"] == "user"], [Message.model_validate(i) for i in DEMO1_CONTENT if i["role"] == "user"], - [ - Message(role="user", content='Create a "2048 game"'), - Message(role="user", content='"IndentationError: expected an indented block"'), - ], + [Message.model_validate(i) for i in DEMO2_CONTENT if i["role"] == "user"], ], ) async def test_mgx(user_messages: List[Message]):