fixbug: fixbug intent

This commit is contained in:
莘权 马 2024-04-01 19:44:00 +08:00
parent f75382b918
commit de53a1ae35
3 changed files with 22 additions and 8 deletions

View file

@ -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)

View file

@ -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]):