feat: merge gitlab:mgx_ops

This commit is contained in:
莘权 马 2024-04-03 15:04:06 +08:00
parent 764a5ba299
commit e2de8131cf
3 changed files with 7 additions and 519 deletions

View file

@ -1,16 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import pytest
from metagpt.actions.intent_detect import (
IntentDetect,
LightIntentDetect,
SentenceIntentDetect,
)
from metagpt.logs import logger
from metagpt.schema import Message
DEMO_CONTENT = [
{
@ -137,54 +126,3 @@ DEMO2_CONTENT = [
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(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)]
rsp = await action.run(messages)
assert isinstance(rsp, Message)
assert action._dialog_intentions
assert action._references
assert action._intent_to_sops
assert action.result
logger.info(action.result.model_dump_json())
@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_light_intent_detect(content: str, context):
action = LightIntentDetect(context=context)
messages = [Message.model_validate(i) for i in json.loads(content)]
rsp = await action.run(messages)
assert isinstance(rsp, Message)
assert action._dialog_intentions
assert action._intent_to_sops
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"])