From e24929efa370bc4ef21dc045bfab0578f9ad22d9 Mon Sep 17 00:00:00 2001 From: Divano Date: Tue, 5 Aug 2025 16:37:28 +0800 Subject: [PATCH] Ce add bad cases (#3215) * add repitation early stop cases * add repitation early stop cases * add bad cases * add bad cases --- test/ce/server/test_DDoS.py | 8 +++++ test/ce/server/test_base_chat.py | 50 +++++++++++++++++++++++++++++++ test/ce/server/test_evil_cases.py | 7 +++++ 3 files changed, 65 insertions(+) create mode 100644 test/ce/server/test_DDoS.py create mode 100644 test/ce/server/test_evil_cases.py diff --git a/test/ce/server/test_DDoS.py b/test/ce/server/test_DDoS.py new file mode 100644 index 000000000..8d2d7afb9 --- /dev/null +++ b/test/ce/server/test_DDoS.py @@ -0,0 +1,8 @@ +#!/bin/env python3 +# -*- coding: utf-8 -*- +# @author DDDivano +# encoding=utf-8 vi:ts=4:sw=4:expandtab:ft=python + +""" +分布式拒绝服务 +""" diff --git a/test/ce/server/test_base_chat.py b/test/ce/server/test_base_chat.py index 73524c13e..24bea05c4 100644 --- a/test/ce/server/test_base_chat.py +++ b/test/ce/server/test_base_chat.py @@ -104,6 +104,9 @@ def test_stop_sequence(): def test_stop_sequence1(): + """ + 不加stop看看是否有影响 + """ data = { "stream": False, "messages": [ @@ -122,6 +125,53 @@ def test_stop_sequence1(): assert "第二段" in content +def test_stop_sequence2(): + """ + stop token长度测试 + """ + data = { + "stream": False, + "stop": ["这是第二段啦啦"], + "messages": [ + { + "role": "user", + "content": "你要严格按照我接下来的话输出,输出冒号后面的内容,请输出:这是第一段。果冻这是第二段啦啦啦啦啦。", + }, + ], + "max_tokens": 50, + "top_p": 0, + } + payload = build_request_payload(TEMPLATE, data) + resp = send_request(URL, payload).json() + content = resp["choices"][0]["message"]["content"] + # token_list = get_token_list(resp) + print("截断输出:", content) + assert "啦啦啦" not in content + + +# def test_stop_sequence3(): +# """ +# stop token 数量测试 +# """ +# data = { +# "stream": False, +# "stop": ["。", "果冻", "果", "冻", "第二", "二"], +# "messages": [ +# { +# "role": "user", +# "content": "你要严格按照我接下来的话输出,输出冒号后面的内容,请输出:这是第一段。果冻这是第二段啦啦啦啦啦。", +# }, +# ], +# "max_tokens": 50, +# "top_p": 0, +# } +# payload = build_request_payload(TEMPLATE, data) +# resp = send_request(URL, payload).json() +# content = resp["choices"][0]["message"]["content"] +# print("截断输出:", content) +# assert "啦啦啦" not in content + + def test_sampling_parameters(): data = { "stream": False, diff --git a/test/ce/server/test_evil_cases.py b/test/ce/server/test_evil_cases.py new file mode 100644 index 000000000..6d5240c11 --- /dev/null +++ b/test/ce/server/test_evil_cases.py @@ -0,0 +1,7 @@ +#!/bin/env python3 +# -*- coding: utf-8 -*- +# @author DDDivano +# encoding=utf-8 vi:ts=4:sw=4:expandtab:ft=python +""" +边缘检测 ,攻击性测试 +"""