File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
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 } "
You can’t perform that action at this time.
0 commit comments