mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-17 15:35:21 +02:00
feat: +SentenceIntentDetect
This commit is contained in:
parent
66b68399eb
commit
edb39a50d3
4 changed files with 69 additions and 15 deletions
|
|
@ -4,7 +4,11 @@ import json
|
|||
|
||||
import pytest
|
||||
|
||||
from metagpt.actions.intent_detect import IntentDetect, LightIntentDetect
|
||||
from metagpt.actions.intent_detect import (
|
||||
IntentDetect,
|
||||
LightIntentDetect,
|
||||
SentenceIntentDetect,
|
||||
)
|
||||
from metagpt.logs import logger
|
||||
from metagpt.schema import Message
|
||||
|
||||
|
|
@ -140,6 +144,7 @@ DEMO3_CONTENT = [
|
|||
"content",
|
||||
[json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT), json.dumps(DEMO3_CONTENT)],
|
||||
)
|
||||
# @pytest.mark.skip
|
||||
async def test_intent_detect(content: str, context):
|
||||
action = IntentDetect(context=context)
|
||||
messages = [Message.model_validate(i) for i in json.loads(content)]
|
||||
|
|
@ -157,6 +162,7 @@ async def test_intent_detect(content: str, context):
|
|||
"content",
|
||||
[json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT), json.dumps(DEMO3_CONTENT)],
|
||||
)
|
||||
# @pytest.mark.skip
|
||||
async def test_light_intent_detect(content: str, context):
|
||||
action = LightIntentDetect(context=context)
|
||||
messages = [Message.model_validate(i) for i in json.loads(content)]
|
||||
|
|
@ -167,5 +173,18 @@ async def test_light_intent_detect(content: str, context):
|
|||
assert action.result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"content",
|
||||
[json.dumps(DEMO1_CONTENT), json.dumps(DEMO_CONTENT), json.dumps(DEMO2_CONTENT), json.dumps(DEMO3_CONTENT)],
|
||||
)
|
||||
# @pytest.mark.skip
|
||||
async def test_sentence_intent(content: str, context):
|
||||
action = SentenceIntentDetect(context=context)
|
||||
messages = [Message.model_validate(i) for i in json.loads(content)]
|
||||
await action.run(messages)
|
||||
assert action.sop is not None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-s"])
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ async def test_mgx_fixbug(user_message: Message, history_messages: List[Message]
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("user_message", [Message.model_validate(i) for i in DEMO3_CONTENT if i.role == "user"])
|
||||
@pytest.mark.parametrize("user_message", [Message.model_validate(i) for i in DEMO3_CONTENT if i["role"] == "user"])
|
||||
@pytest.mark.skip
|
||||
async def test_git_import(user_message, context):
|
||||
mgx = MGX(context=context, tools=["<all>"])
|
||||
await mgx.run(user_message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue