mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-30 11:26:23 +02:00
add:
1.moderation tools 2.unittest
This commit is contained in:
parent
443c044990
commit
304a03244c
2 changed files with 82 additions and 0 deletions
42
tests/metagpt/tools/test_moderation.py
Normal file
42
tests/metagpt/tools/test_moderation.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/9/26 14:46
|
||||
@Author : zhanglei
|
||||
@File : test_translate.py
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from metagpt.tools.moderation import Moderation
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("content",),
|
||||
[
|
||||
[
|
||||
["I will kill you", "The weather is really nice today", "I want to hit you"],
|
||||
]
|
||||
],
|
||||
)
|
||||
def test_moderation(content):
|
||||
moderation = Moderation()
|
||||
results = moderation.moderation(content=content)
|
||||
assert isinstance(results, list)
|
||||
assert len(results) == len(content)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
("content",),
|
||||
[
|
||||
[
|
||||
["I will kill you", "The weather is really nice today", "I want to hit you"],
|
||||
]
|
||||
],
|
||||
)
|
||||
async def test_amoderation(content):
|
||||
moderation = Moderation()
|
||||
results = await moderation.amoderation(content=content)
|
||||
assert isinstance(results, list)
|
||||
assert len(results) == len(content)
|
||||
Loading…
Add table
Add a link
Reference in a new issue