Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,362 changes: 1,180 additions & 182 deletions c/openai_server.py

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions c/tests/fixtures/captured_lmeval_request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"method": "POST",
"path": "/v1/completions",
"headers": {
"Host": "127.0.0.1:8812",
"User-Agent": "python-requests/2.34.2",
"Accept-Encoding": "gzip, deflate",
"Accept": "*/*",
"Connection": "keep-alive",
"Authorization": "Bearer ",
"Content-Length": "725",
"Content-Type": "application/json"
},
"body_text": "{\"model\": \"glm-5.2-colibri\", \"prompt\": [[154822, 154824, 14572, 25, 55638, 614, 1012, 2952, 311, 5656, 20683, 504, 264, 34184, 1119, 279, 32616, 315, 264, 12722, 52938, 13, 3197, 279, 52938, 87894, 11, 432, 18611, 14065, 429, 5610, 264, 12827, 1730, 304, 34184, 80264, 13, 1096, 12827, 646, 1221, 387, 27341, 323, 1483, 311, 1281, 3746, 714, 29037, 7236, 369, 17409, 15768, 96457, 11, 77920, 11, 323, 14126, 13, 576, 2297, 1558, 537, 5240, 279, 52938, 894, 6646, 11, 714, 1045, 1251, 1744, 429, 432, 374, 537, 1290, 311, 912, 20683, 504, 279, 32616, 315, 825, 9859, 311, 2441, 13, 15908, 3409, 1850, 16539, 419, 4643, 5267, 16127, 25, 220, 6955]], \"temperature\": 0, \"max_tokens\": 1, \"logprobs\": 1, \"seed\": 1234, \"echo\": true}",
"body_json": {
"model": "glm-5.2-colibri",
"prompt": [
[
154822,
154824,
14572,
25,
55638,
614,
1012,
2952,
311,
5656,
20683,
504,
264,
34184,
1119,
279,
32616,
315,
264,
12722,
52938,
13,
3197,
279,
52938,
87894,
11,
432,
18611,
14065,
429,
5610,
264,
12827,
1730,
304,
34184,
80264,
13,
1096,
12827,
646,
1221,
387,
27341,
323,
1483,
311,
1281,
3746,
714,
29037,
7236,
369,
17409,
15768,
96457,
11,
77920,
11,
323,
14126,
13,
576,
2297,
1558,
537,
5240,
279,
52938,
894,
6646,
11,
714,
1045,
1251,
1744,
429,
432,
374,
537,
1290,
311,
912,
20683,
504,
279,
32616,
315,
825,
9859,
311,
2441,
13,
15908,
3409,
1850,
16539,
419,
4643,
5267,
16127,
25,
220,
6955
]
],
"temperature": 0,
"max_tokens": 1,
"logprobs": 1,
"seed": 1234,
"echo": true
}
}
11 changes: 6 additions & 5 deletions c/tests/golden_fixture_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
python3 tests/golden_fixture_capture.py diff fixtures_pre fixtures_post

Battery: chat, chat+tools, chat streaming, completions without logprobs, and
the error cases whose behavior must not move (seed 400, array-prompt 400,
logprobs 400, out-of-range temperature 400) plus /v1/models.
the error/no-op cases whose behavior must not move (seed accepted-and-ignored,
an array `prompt` classified as one flat token-id prompt, logprobs served on
the glm engine, out-of-range temperature 400) plus /v1/models.

Normalization: every "id"/"created" field (recursively, and per SSE event) is
replaced with a constant; nothing else is touched. Generation-bearing requests
Expand Down Expand Up @@ -76,11 +77,11 @@ def battery(model):
("completions_stop", "POST", "/v1/completions",
{"model": model, "prompt": "Count: one, two,",
"max_tokens": 16, "temperature": 0, "stop": ["five"]}),
("err_seed", "POST", "/v1/completions",
("seed_accepted", "POST", "/v1/completions",
{"model": model, "prompt": "hello", "max_tokens": 1, "seed": 1234}),
("err_array_prompt", "POST", "/v1/completions",
("array_prompt_token_ids", "POST", "/v1/completions",
{"model": model, "prompt": [1, 2, 3], "max_tokens": 1}),
("err_logprobs", "POST", "/v1/completions",
("logprobs_served", "POST", "/v1/completions",
{"model": model, "prompt": "hello", "max_tokens": 1, "logprobs": 1}),
("err_bad_temperature", "POST", "/v1/chat/completions",
{"model": model, "messages": chat_messages,
Expand Down
2 changes: 2 additions & 0 deletions c/tests/test_anthropic_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def generate(self, prompt, maximum, temperature, top_p, on_text, cache_slot=0,
on_tool=None):
self.prompts.append(prompt)
self.emitted = 0
if on_accept is not None: # simulate the engine's ACCEPT frame (#597)
on_accept({"prompt_tokens": 11})
for chunk in self.script:
on_text(chunk)
self.emitted += 1
Expand Down
Loading
Loading