MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / test_unstream_without_logprobs

Function test_unstream_without_logprobs

tests/ce/server/test_logprobs.py:41–67  ·  view source on GitHub ↗

测试非流式响应关闭 logprobs 后,返回结果中不包含 logprobs 字段。

()

Source from the content-addressed store, hash-verified

39
40
41def test_unstream_without_logprobs():
42 """
43 测试非流式响应关闭 logprobs 后,返回结果中不包含 logprobs 字段。
44 """
45 data = {
46 "stream": False,
47 "logprobs": False,
48 "top_logprobs": None,
49 "messages": [
50 {"role": "system", "content": "You are a helpful assistant."},
51 {"role": "user", "content": "牛顿的三大运动定律是什么?"},
52 ],
53 "max_tokens": 3,
54 }
55
56 # 构建请求并发送
57 payload = build_request_payload(TEMPLATE, data)
58 response = send_request(URL, payload)
59 print(json.dumps(response.json(), indent=2, ensure_ascii=False))
60 resp_json = response.json()
61
62 # 校验返回内容与 logprobs 字段
63 assert resp_json["choices"][0]["message"]["content"] == "牛顿的"
64 assert resp_json["choices"][0]["logprobs"] is None
65 assert resp_json["usage"]["prompt_tokens"] == 22
66 assert resp_json["usage"]["completion_tokens"] == 3
67 assert resp_json["usage"]["total_tokens"] == 25
68
69
70def test_stream_with_logprobs():

Callers 1

test_logprobs.pyFile · 0.85

Calls 3

build_request_payloadFunction · 0.90
send_requestFunction · 0.90
printFunction · 0.85

Tested by

no test coverage detected