Skip to content

Commit 147b88b

Browse files
fix(inference): improve chat completions OpenAI conformance
1 parent d6a79d0 commit 147b88b

7 files changed

Lines changed: 45 additions & 53 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 102
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-36a0290facb461859b027e5f50206ce9c05fc5d0e8366d1e210ade0bda556936.yml
3-
openapi_spec_hash: 7ca2a28f0cc0958f01709c749cc3b7a4
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-1aedf17a2c2aba13036e748a3e9d7811fb9e423e9dc86f9913a9cd17590e4f0b.yml
3+
openapi_spec_hash: 878315e3cf9cbe546888a24b8b819660
44
config_hash: d1db834ac019b3bb2e260c9e37dcb5d1

src/llama_stack_client/types/chat/completion_create_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ class MessageOpenAIAssistantMessageParamInputContentListOpenAIChatCompletionCont
258258
class MessageOpenAIAssistantMessageParamInputToolCallFunction(TypedDict, total=False):
259259
"""Function call details for OpenAI-compatible tool calls."""
260260

261-
arguments: Optional[str]
261+
arguments: Required[str]
262262
"""Arguments to pass to the function as a JSON string."""
263263

264-
name: Optional[str]
264+
name: Required[str]
265265
"""Name of the function to call."""
266266

267267

src/llama_stack_client/types/chat/completion_create_response.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@
3232
class ChoiceMessageFunctionCall(BaseModel):
3333
"""Deprecated: the name and arguments of a function that should be called."""
3434

35-
arguments: Optional[str] = None
35+
arguments: str
3636
"""Arguments to pass to the function as a JSON string."""
3737

38-
name: Optional[str] = None
38+
name: str
3939
"""Name of the function to call."""
4040

4141

4242
class ChoiceMessageToolCallFunction(BaseModel):
4343
"""Function call details for OpenAI-compatible tool calls."""
4444

45-
arguments: Optional[str] = None
45+
arguments: str
4646
"""Arguments to pass to the function as a JSON string."""
4747

48-
name: Optional[str] = None
48+
name: str
4949
"""Name of the function to call."""
5050

5151

@@ -157,9 +157,7 @@ class ChoiceLogprobsRefusal(BaseModel):
157157

158158

159159
class ChoiceLogprobs(BaseModel):
160-
"""
161-
The log probabilities for the tokens in the message from an OpenAI-compatible chat completion response.
162-
"""
160+
"""The log probabilities for the tokens in the message."""
163161

164162
content: Optional[List[ChoiceLogprobsContent]] = None
165163
"""The log probabilities for the tokens in the message."""
@@ -181,10 +179,7 @@ class Choice(BaseModel):
181179
"""The message from the model."""
182180

183181
logprobs: Optional[ChoiceLogprobs] = None
184-
"""
185-
The log probabilities for the tokens in the message from an OpenAI-compatible
186-
chat completion response.
187-
"""
182+
"""The log probabilities for the tokens in the message."""
188183

189184

190185
class UsageCompletionTokensDetails(BaseModel):
@@ -241,5 +236,8 @@ class CompletionCreateResponse(BaseModel):
241236
service_tier: Optional[str] = None
242237
"""The service tier that was used for this response."""
243238

239+
system_fingerprint: Optional[str] = None
240+
"""System fingerprint for this completion."""
241+
244242
usage: Optional[Usage] = None
245243
"""Token usage information for the completion."""

src/llama_stack_client/types/chat/completion_list_response.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,20 @@
5454
class DataChoiceMessageFunctionCall(BaseModel):
5555
"""Deprecated: the name and arguments of a function that should be called."""
5656

57-
arguments: Optional[str] = None
57+
arguments: str
5858
"""Arguments to pass to the function as a JSON string."""
5959

60-
name: Optional[str] = None
60+
name: str
6161
"""Name of the function to call."""
6262

6363

6464
class DataChoiceMessageToolCallFunction(BaseModel):
6565
"""Function call details for OpenAI-compatible tool calls."""
6666

67-
arguments: Optional[str] = None
67+
arguments: str
6868
"""Arguments to pass to the function as a JSON string."""
6969

70-
name: Optional[str] = None
70+
name: str
7171
"""Name of the function to call."""
7272

7373

@@ -179,9 +179,7 @@ class DataChoiceLogprobsRefusal(BaseModel):
179179

180180

181181
class DataChoiceLogprobs(BaseModel):
182-
"""
183-
The log probabilities for the tokens in the message from an OpenAI-compatible chat completion response.
184-
"""
182+
"""The log probabilities for the tokens in the message."""
185183

186184
content: Optional[List[DataChoiceLogprobsContent]] = None
187185
"""The log probabilities for the tokens in the message."""
@@ -203,10 +201,7 @@ class DataChoice(BaseModel):
203201
"""The message from the model."""
204202

205203
logprobs: Optional[DataChoiceLogprobs] = None
206-
"""
207-
The log probabilities for the tokens in the message from an OpenAI-compatible
208-
chat completion response.
209-
"""
204+
"""The log probabilities for the tokens in the message."""
210205

211206

212207
class DataInputMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartTextParam(
@@ -339,10 +334,10 @@ class DataInputMessageOpenAIAssistantMessageParamOutputContentListOpenAIChatComp
339334
class DataInputMessageOpenAIAssistantMessageParamOutputToolCallFunction(BaseModel):
340335
"""Function call details for OpenAI-compatible tool calls."""
341336

342-
arguments: Optional[str] = None
337+
arguments: str
343338
"""Arguments to pass to the function as a JSON string."""
344339

345-
name: Optional[str] = None
340+
name: str
346341
"""Name of the function to call."""
347342

348343

@@ -513,6 +508,9 @@ class Data(BaseModel):
513508
service_tier: Optional[str] = None
514509
"""The service tier that was used for this response."""
515510

511+
system_fingerprint: Optional[str] = None
512+
"""System fingerprint for this completion."""
513+
516514
usage: Optional[DataUsage] = None
517515
"""Token usage information for the completion."""
518516

src/llama_stack_client/types/chat/completion_retrieve_response.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@
5353
class ChoiceMessageFunctionCall(BaseModel):
5454
"""Deprecated: the name and arguments of a function that should be called."""
5555

56-
arguments: Optional[str] = None
56+
arguments: str
5757
"""Arguments to pass to the function as a JSON string."""
5858

59-
name: Optional[str] = None
59+
name: str
6060
"""Name of the function to call."""
6161

6262

6363
class ChoiceMessageToolCallFunction(BaseModel):
6464
"""Function call details for OpenAI-compatible tool calls."""
6565

66-
arguments: Optional[str] = None
66+
arguments: str
6767
"""Arguments to pass to the function as a JSON string."""
6868

69-
name: Optional[str] = None
69+
name: str
7070
"""Name of the function to call."""
7171

7272

@@ -178,9 +178,7 @@ class ChoiceLogprobsRefusal(BaseModel):
178178

179179

180180
class ChoiceLogprobs(BaseModel):
181-
"""
182-
The log probabilities for the tokens in the message from an OpenAI-compatible chat completion response.
183-
"""
181+
"""The log probabilities for the tokens in the message."""
184182

185183
content: Optional[List[ChoiceLogprobsContent]] = None
186184
"""The log probabilities for the tokens in the message."""
@@ -202,10 +200,7 @@ class Choice(BaseModel):
202200
"""The message from the model."""
203201

204202
logprobs: Optional[ChoiceLogprobs] = None
205-
"""
206-
The log probabilities for the tokens in the message from an OpenAI-compatible
207-
chat completion response.
208-
"""
203+
"""The log probabilities for the tokens in the message."""
209204

210205

211206
class InputMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartTextParam(
@@ -336,10 +331,10 @@ class InputMessageOpenAIAssistantMessageParamOutputContentListOpenAIChatCompleti
336331
class InputMessageOpenAIAssistantMessageParamOutputToolCallFunction(BaseModel):
337332
"""Function call details for OpenAI-compatible tool calls."""
338333

339-
arguments: Optional[str] = None
334+
arguments: str
340335
"""Arguments to pass to the function as a JSON string."""
341336

342-
name: Optional[str] = None
337+
name: str
343338
"""Name of the function to call."""
344339

345340

@@ -510,5 +505,8 @@ class CompletionRetrieveResponse(BaseModel):
510505
service_tier: Optional[str] = None
511506
"""The service tier that was used for this response."""
512507

508+
system_fingerprint: Optional[str] = None
509+
"""System fingerprint for this completion."""
510+
513511
usage: Optional[Usage] = None
514512
"""Token usage information for the completion."""

src/llama_stack_client/types/chat_completion_chunk.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
class ChoiceDeltaToolCallFunction(BaseModel):
3232
"""Function call details for OpenAI-compatible tool calls."""
3333

34-
arguments: Optional[str] = None
34+
arguments: str
3535
"""Arguments to pass to the function as a JSON string."""
3636

37-
name: Optional[str] = None
37+
name: str
3838
"""Name of the function to call."""
3939

4040

@@ -66,7 +66,7 @@ class ChoiceDelta(BaseModel):
6666
refusal: Optional[str] = None
6767
"""The refusal of the delta."""
6868

69-
role: Optional[str] = None
69+
role: Optional[Literal["developer", "system", "user", "assistant", "tool"]] = None
7070
"""The role of the delta."""
7171

7272
tool_calls: Optional[List[ChoiceDeltaToolCall]] = None
@@ -140,9 +140,7 @@ class ChoiceLogprobsRefusal(BaseModel):
140140

141141

142142
class ChoiceLogprobs(BaseModel):
143-
"""
144-
The log probabilities for the tokens in the message from an OpenAI-compatible chat completion response.
145-
"""
143+
"""The log probabilities for the tokens in the message."""
146144

147145
content: Optional[List[ChoiceLogprobsContent]] = None
148146
"""The log probabilities for the tokens in the message."""
@@ -164,10 +162,7 @@ class Choice(BaseModel):
164162
"""The reason the model stopped generating."""
165163

166164
logprobs: Optional[ChoiceLogprobs] = None
167-
"""
168-
The log probabilities for the tokens in the message from an OpenAI-compatible
169-
chat completion response.
170-
"""
165+
"""The log probabilities for the tokens in the message."""
171166

172167

173168
class UsageCompletionTokensDetails(BaseModel):
@@ -228,6 +223,9 @@ class ChatCompletionChunk(BaseModel):
228223
service_tier: Optional[str] = None
229224
"""The service tier that was used for this response."""
230225

226+
system_fingerprint: Optional[str] = None
227+
"""System fingerprint for this completion chunk."""
228+
231229
usage: Optional[Usage] = None
232230
"""
233231
Token usage information (typically included in final chunk with stream_options).

src/llama_stack_client/types/safety_run_shield_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ class MessageOpenAIAssistantMessageParamInputContentListOpenAIChatCompletionCont
177177
class MessageOpenAIAssistantMessageParamInputToolCallFunction(TypedDict, total=False):
178178
"""Function call details for OpenAI-compatible tool calls."""
179179

180-
arguments: Optional[str]
180+
arguments: Required[str]
181181
"""Arguments to pass to the function as a JSON string."""
182182

183-
name: Optional[str]
183+
name: Required[str]
184184
"""Name of the function to call."""
185185

186186

0 commit comments

Comments
 (0)