Skip to content

Commit e066071

Browse files
committed
add test
1 parent 2a7728f commit e066071

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/server/tests/unit/test_chat_completion.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,22 @@ def make_cmpl_request():
477477
assert last_progress["total"] > 0
478478
assert last_progress["processed"] == last_progress["total"]
479479
assert total_batch_count == batch_count
480+
481+
482+
def test_chat_completions_multiple_choices():
483+
global server
484+
server.start()
485+
res = server.make_request("POST", "/chat/completions", data={
486+
"max_tokens": 8,
487+
"n": 2,
488+
"messages": [
489+
{"role": "system", "content": "Book"},
490+
{"role": "user", "content": "What is the best book"},
491+
],
492+
})
493+
assert res.status_code == 200
494+
assert len(res.body["choices"]) == 2
495+
for choice in res.body["choices"]:
496+
assert "assistant" == choice["message"]["role"]
497+
assert match_regex("Suddenly", choice["message"]["content"])
498+
assert choice["finish_reason"] == "length"

0 commit comments

Comments
 (0)