Skip to content

Commit dc5f05f

Browse files
drbhNarsil
andauthored
Pr 3003 ci branch (#3007)
* change ChatCompletionChunk to align with "OpenAI Chat Completions streaming API" Moving after tool_calls2 Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> add in Buffering.. Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> fix: handle usage outside of stream state and add tests Simplifying everything quite a bit. Remove the unused model_dump. Clippy. Clippy ? Ruff. Uppgrade the flake for latest transformers. Upgrade after rebase. Remove potential footgun. Fix completion test. * Clippy. * Tweak for multi prompt. * Ruff. * Update the snapshot a bit. --------- Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
1 parent 124398f commit dc5f05f

14 files changed

+776
-239
lines changed

flake.lock

Lines changed: 99 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration-tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from openai.types.chat.chat_completion_chunk import (
99
ChatCompletionChunk as OAIChatCompletionChunk,
1010
)
11+
from openai.types.completion import Completion as OAICompletion
1112
import requests
1213

1314

@@ -39,7 +40,6 @@ def request(self, *args, **kwargs):
3940
from aiohttp import ClientConnectorError, ClientOSError, ServerDisconnectedError
4041
from docker.errors import NotFound
4142
from syrupy.extensions.json import JSONSnapshotExtension
42-
4343
from text_generation import AsyncClient
4444
from text_generation.types import (
4545
BestOfSequence,
@@ -133,6 +133,7 @@ def _serialize(
133133
or isinstance(data, ChatCompletionComplete)
134134
or isinstance(data, Completion)
135135
or isinstance(data, OAIChatCompletionChunk)
136+
or isinstance(data, OAICompletion)
136137
):
137138
data = data.model_dump()
138139
elif isinstance(data, ChatCompletionStreamOutput) or isinstance(
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[
2+
{
3+
"choices": [
4+
{
5+
"delta": {
6+
"content": "OK",
7+
"role": "assistant",
8+
"tool_calls": null
9+
},
10+
"finish_reason": null,
11+
"index": 0,
12+
"logprobs": null
13+
}
14+
],
15+
"created": 1741265520,
16+
"id": "",
17+
"model": "meta-llama/Llama-3.1-8B-Instruct",
18+
"object": "chat.completion.chunk",
19+
"system_fingerprint": "3.1.2-dev0-native",
20+
"usage": null
21+
},
22+
{
23+
"choices": [
24+
{
25+
"delta": {
26+
"content": "!",
27+
"role": "assistant",
28+
"tool_calls": null
29+
},
30+
"finish_reason": null,
31+
"index": 0,
32+
"logprobs": null
33+
}
34+
],
35+
"created": 1741265520,
36+
"id": "",
37+
"model": "meta-llama/Llama-3.1-8B-Instruct",
38+
"object": "chat.completion.chunk",
39+
"system_fingerprint": "3.1.2-dev0-native",
40+
"usage": null
41+
},
42+
{
43+
"choices": [
44+
{
45+
"delta": {
46+
"content": "",
47+
"role": "assistant",
48+
"tool_calls": null
49+
},
50+
"finish_reason": "stop",
51+
"index": 0,
52+
"logprobs": null
53+
}
54+
],
55+
"created": 1741265520,
56+
"id": "",
57+
"model": "meta-llama/Llama-3.1-8B-Instruct",
58+
"object": "chat.completion.chunk",
59+
"system_fingerprint": "3.1.2-dev0-native",
60+
"usage": null
61+
}
62+
]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[
2+
{
3+
"choices": [
4+
{
5+
"delta": {
6+
"content": "OK",
7+
"role": "assistant",
8+
"tool_calls": null
9+
},
10+
"finish_reason": null,
11+
"index": 0,
12+
"logprobs": null
13+
}
14+
],
15+
"created": 1741266005,
16+
"id": "",
17+
"model": "meta-llama/Llama-3.1-8B-Instruct",
18+
"object": "chat.completion.chunk",
19+
"system_fingerprint": "3.1.2-dev0-native",
20+
"usage": null
21+
},
22+
{
23+
"choices": [
24+
{
25+
"delta": {
26+
"content": "!",
27+
"role": "assistant",
28+
"tool_calls": null
29+
},
30+
"finish_reason": null,
31+
"index": 0,
32+
"logprobs": null
33+
}
34+
],
35+
"created": 1741266005,
36+
"id": "",
37+
"model": "meta-llama/Llama-3.1-8B-Instruct",
38+
"object": "chat.completion.chunk",
39+
"system_fingerprint": "3.1.2-dev0-native",
40+
"usage": null
41+
},
42+
{
43+
"choices": [
44+
{
45+
"delta": {
46+
"content": "",
47+
"role": "assistant",
48+
"tool_calls": null
49+
},
50+
"finish_reason": "stop",
51+
"index": 0,
52+
"logprobs": null
53+
}
54+
],
55+
"created": 1741266005,
56+
"id": "",
57+
"model": "meta-llama/Llama-3.1-8B-Instruct",
58+
"object": "chat.completion.chunk",
59+
"system_fingerprint": "3.1.2-dev0-native",
60+
"usage": null
61+
},
62+
{
63+
"choices": [],
64+
"created": 1741266005,
65+
"id": "",
66+
"model": "meta-llama/Llama-3.1-8B-Instruct",
67+
"object": "chat.completion.chunk",
68+
"system_fingerprint": "3.1.2-dev0-native",
69+
"usage": {
70+
"completion_tokens": 3,
71+
"prompt_tokens": 39,
72+
"total_tokens": 42
73+
}
74+
}
75+
]

0 commit comments

Comments
 (0)