Skip to content

Commit 256a82b

Browse files
xjkmfaxujing43
andauthored
Add ci case for min token and max token (#3229)
Co-authored-by: xujing43 <[email protected]>
1 parent 36dc734 commit 256a82b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
# @author xujing43
4+
# encoding=utf-8 vi:ts=4:sw=4:expandtab:ft=python
5+
6+
"""
7+
Boundary value checking for API parameters
8+
"""
9+
10+
import json
11+
12+
from core import (
13+
TEMPLATE,
14+
URL,
15+
build_request_payload,
16+
send_request,
17+
)
18+
19+
def test_max_min_1_token():
20+
data = {
21+
"stream": False,
22+
"messages": [{"role": "user", "content": "非洲的首都是?"}],
23+
"max_tokens": 1,
24+
"metadata": {
25+
"min_tokens": 1
26+
},
27+
}
28+
payload = build_request_payload(TEMPLATE, data)
29+
response = send_request(URL, payload).json()
30+
31+
response_object = response["object"]
32+
assert "error" not in response_object, f"响应中包含错误信息: {response_object}"
33+
completion_tokens = response["usage"]["completion_tokens"]
34+
assert completion_tokens == 1, f"实际生成的token数为: {completion_tokens}, 应该为1"
35+
finish_reason = response["choices"][0]["finish_reason"]
36+
assert finish_reason == "length", f"内容不可能完整生成, 但实际finish_reason为: {response}"

0 commit comments

Comments
 (0)