From 256a82b0b3a768b63b10562be2c6cada8205f794 Mon Sep 17 00:00:00 2001 From: xjkmfa <108254620+xjkmfa@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:10:57 +0800 Subject: [PATCH] Add ci case for min token and max token (#3229) Co-authored-by: xujing43 --- test/ce/server/test_params_boundary.py | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/ce/server/test_params_boundary.py diff --git a/test/ce/server/test_params_boundary.py b/test/ce/server/test_params_boundary.py new file mode 100644 index 000000000..794e6702e --- /dev/null +++ b/test/ce/server/test_params_boundary.py @@ -0,0 +1,36 @@ +#!/bin/env python3 +# -*- coding: utf-8 -*- +# @author xujing43 +# encoding=utf-8 vi:ts=4:sw=4:expandtab:ft=python + +""" +Boundary value checking for API parameters +""" + +import json + +from core import ( + TEMPLATE, + URL, + build_request_payload, + send_request, +) + +def test_max_min_1_token(): + data = { + "stream": False, + "messages": [{"role": "user", "content": "非洲的首都是?"}], + "max_tokens": 1, + "metadata": { + "min_tokens": 1 + }, + } + payload = build_request_payload(TEMPLATE, data) + response = send_request(URL, payload).json() + + response_object = response["object"] + assert "error" not in response_object, f"响应中包含错误信息: {response_object}" + completion_tokens = response["usage"]["completion_tokens"] + assert completion_tokens == 1, f"实际生成的token数为: {completion_tokens}, 应该为1" + finish_reason = response["choices"][0]["finish_reason"] + assert finish_reason == "length", f"内容不可能完整生成, 但实际finish_reason为: {response}" \ No newline at end of file