Skip to content

Commit e58e2e4

Browse files
fix(inference): use flat response message model for chat/completions
1 parent 0e3e262 commit e58e2e4

File tree

4 files changed

+87
-656
lines changed

4 files changed

+87
-656
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 108
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-d6858fead41d2db69218aca5b3b7bc8fe300a1025484c486c3cb304ed39c48bc.yml
3-
openapi_spec_hash: bb1cc7aff177fad17663182b20e964b6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-5c711749dbcc9575d8997ac3e0b2a2e45e20ef8de212cdb0fcceb7009b34cc48.yml
3+
openapi_spec_hash: 8107eabfac6b422964ac2a6688844181
44
config_hash: 07e70c7f1980785685ea4f2618dfde62

src/llama_stack_client/types/chat/completion_create_response.py

Lines changed: 29 additions & 218 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,18 @@
66

77
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
88

9-
from typing import List, Union, Optional
10-
from typing_extensions import Literal, Annotated, TypeAlias
9+
from typing import Dict, List, Optional
10+
from typing_extensions import Literal
1111

12-
from ..._utils import PropertyInfo
1312
from ..._models import BaseModel
1413

1514
__all__ = [
1615
"CompletionCreateResponse",
1716
"Choice",
1817
"ChoiceMessage",
19-
"ChoiceMessageOpenAIUserMessageParamOutput",
20-
"ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFile",
21-
"ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartTextParam",
22-
"ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartImageParam",
23-
"ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartImageParamImageURL",
24-
"ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIFile",
25-
"ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIFileFile",
26-
"ChoiceMessageOpenAISystemMessageParam",
27-
"ChoiceMessageOpenAISystemMessageParamContentListOpenAIChatCompletionContentPartTextParam",
28-
"ChoiceMessageOpenAIAssistantMessageParamOutput",
29-
"ChoiceMessageOpenAIAssistantMessageParamOutputContentListOpenAIChatCompletionContentPartTextParam",
30-
"ChoiceMessageOpenAIAssistantMessageParamOutputToolCall",
31-
"ChoiceMessageOpenAIAssistantMessageParamOutputToolCallFunction",
32-
"ChoiceMessageOpenAIToolMessageParam",
33-
"ChoiceMessageOpenAIToolMessageParamContentListOpenAIChatCompletionContentPartTextParam",
34-
"ChoiceMessageOpenAIDeveloperMessageParam",
35-
"ChoiceMessageOpenAIDeveloperMessageParamContentListOpenAIChatCompletionContentPartTextParam",
18+
"ChoiceMessageFunctionCall",
19+
"ChoiceMessageToolCall",
20+
"ChoiceMessageToolCallFunction",
3621
"ChoiceLogprobs",
3722
"ChoiceLogprobsContent",
3823
"ChoiceLogprobsContentTopLogprob",
@@ -44,132 +29,17 @@
4429
]
4530

4631

47-
class ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartTextParam(
48-
BaseModel
49-
):
50-
"""Text content part for OpenAI-compatible chat completion messages."""
32+
class ChoiceMessageFunctionCall(BaseModel):
33+
"""Deprecated: the name and arguments of a function that should be called."""
5134

52-
text: str
53-
"""The text content of the message."""
54-
55-
type: Optional[Literal["text"]] = None
56-
"""Must be 'text' to identify this as text content."""
57-
58-
59-
class ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartImageParamImageURL(
60-
BaseModel
61-
):
62-
"""Image URL specification and processing details."""
63-
64-
url: str
65-
"""URL of the image to include in the message."""
66-
67-
detail: Optional[Literal["low", "high", "auto"]] = None
68-
"""Level of detail for image processing. Can be 'low', 'high', or 'auto'."""
69-
70-
71-
class ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartImageParam(
72-
BaseModel
73-
):
74-
"""Image content part for OpenAI-compatible chat completion messages."""
75-
76-
image_url: ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartImageParamImageURL
77-
"""Image URL specification and processing details."""
78-
79-
type: Optional[Literal["image_url"]] = None
80-
"""Must be 'image_url' to identify this as image content."""
81-
82-
83-
class ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIFileFile(
84-
BaseModel
85-
):
86-
"""File specification."""
87-
88-
file_data: Optional[str] = None
89-
"""Base64-encoded file data."""
90-
91-
file_id: Optional[str] = None
92-
"""ID of an uploaded file."""
93-
94-
filename: Optional[str] = None
95-
"""Name of the file."""
96-
97-
98-
class ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIFile(
99-
BaseModel
100-
):
101-
file: ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIFileFile
102-
"""File specification."""
103-
104-
type: Optional[Literal["file"]] = None
105-
"""Must be 'file' to identify this as file content."""
106-
107-
108-
ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFile: TypeAlias = Annotated[
109-
Union[
110-
ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartTextParam,
111-
ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIChatCompletionContentPartImageParam,
112-
ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileOpenAIFile,
113-
],
114-
PropertyInfo(discriminator="type"),
115-
]
116-
117-
118-
class ChoiceMessageOpenAIUserMessageParamOutput(BaseModel):
119-
"""A message from the user in an OpenAI-compatible chat completion request."""
120-
121-
content: Union[
122-
str,
123-
List[
124-
ChoiceMessageOpenAIUserMessageParamOutputContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFile
125-
],
126-
]
127-
"""The content of the message, which can include text and other media."""
128-
129-
name: Optional[str] = None
130-
"""The name of the user message participant."""
131-
132-
role: Optional[Literal["user"]] = None
133-
"""Must be 'user' to identify this as a user message."""
134-
135-
136-
class ChoiceMessageOpenAISystemMessageParamContentListOpenAIChatCompletionContentPartTextParam(BaseModel):
137-
"""Text content part for OpenAI-compatible chat completion messages."""
138-
139-
text: str
140-
"""The text content of the message."""
141-
142-
type: Optional[Literal["text"]] = None
143-
"""Must be 'text' to identify this as text content."""
144-
145-
146-
class ChoiceMessageOpenAISystemMessageParam(BaseModel):
147-
"""A system message providing instructions or context to the model."""
148-
149-
content: Union[str, List[ChoiceMessageOpenAISystemMessageParamContentListOpenAIChatCompletionContentPartTextParam]]
150-
"""The content of the 'system prompt'.
151-
152-
If multiple system messages are provided, they are concatenated.
153-
"""
35+
arguments: Optional[str] = None
36+
"""Arguments to pass to the function as a JSON string."""
15437

15538
name: Optional[str] = None
156-
"""The name of the system message participant."""
157-
158-
role: Optional[Literal["system"]] = None
159-
"""Must be 'system' to identify this as a system message."""
160-
161-
162-
class ChoiceMessageOpenAIAssistantMessageParamOutputContentListOpenAIChatCompletionContentPartTextParam(BaseModel):
163-
"""Text content part for OpenAI-compatible chat completion messages."""
164-
165-
text: str
166-
"""The text content of the message."""
167-
168-
type: Optional[Literal["text"]] = None
169-
"""Must be 'text' to identify this as text content."""
39+
"""Name of the function to call."""
17040

17141

172-
class ChoiceMessageOpenAIAssistantMessageParamOutputToolCallFunction(BaseModel):
42+
class ChoiceMessageToolCallFunction(BaseModel):
17343
"""Function call details for OpenAI-compatible tool calls."""
17444

17545
arguments: Optional[str] = None
@@ -179,13 +49,13 @@ class ChoiceMessageOpenAIAssistantMessageParamOutputToolCallFunction(BaseModel):
17949
"""Name of the function to call."""
18050

18151

182-
class ChoiceMessageOpenAIAssistantMessageParamOutputToolCall(BaseModel):
52+
class ChoiceMessageToolCall(BaseModel):
18353
"""Tool call specification for OpenAI-compatible chat completion responses."""
18454

18555
id: Optional[str] = None
18656
"""Unique identifier for the tool call."""
18757

188-
function: Optional[ChoiceMessageOpenAIAssistantMessageParamOutputToolCallFunction] = None
58+
function: Optional[ChoiceMessageToolCallFunction] = None
18959
"""Function call details for OpenAI-compatible tool calls."""
19060

19161
index: Optional[int] = None
@@ -195,88 +65,29 @@ class ChoiceMessageOpenAIAssistantMessageParamOutputToolCall(BaseModel):
19565
"""Must be 'function' to identify this as a function call."""
19666

19767

198-
class ChoiceMessageOpenAIAssistantMessageParamOutput(BaseModel):
199-
"""
200-
A message containing the model's (assistant) response in an OpenAI-compatible chat completion request.
201-
"""
202-
203-
content: Union[
204-
str,
205-
List[ChoiceMessageOpenAIAssistantMessageParamOutputContentListOpenAIChatCompletionContentPartTextParam],
206-
None,
207-
] = None
208-
"""The content of the model's response."""
209-
210-
name: Optional[str] = None
211-
"""The name of the assistant message participant."""
212-
213-
role: Optional[Literal["assistant"]] = None
214-
"""Must be 'assistant' to identify this as the model's response."""
215-
216-
tool_calls: Optional[List[ChoiceMessageOpenAIAssistantMessageParamOutputToolCall]] = None
217-
"""List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object."""
218-
219-
220-
class ChoiceMessageOpenAIToolMessageParamContentListOpenAIChatCompletionContentPartTextParam(BaseModel):
221-
"""Text content part for OpenAI-compatible chat completion messages."""
222-
223-
text: str
224-
"""The text content of the message."""
225-
226-
type: Optional[Literal["text"]] = None
227-
"""Must be 'text' to identify this as text content."""
228-
229-
230-
class ChoiceMessageOpenAIToolMessageParam(BaseModel):
231-
"""
232-
A message representing the result of a tool invocation in an OpenAI-compatible chat completion request.
233-
"""
234-
235-
content: Union[str, List[ChoiceMessageOpenAIToolMessageParamContentListOpenAIChatCompletionContentPartTextParam]]
236-
"""The response content from the tool."""
237-
238-
tool_call_id: str
239-
"""Unique identifier for the tool call this response is for."""
240-
241-
role: Optional[Literal["tool"]] = None
242-
"""Must be 'tool' to identify this as a tool response."""
243-
244-
245-
class ChoiceMessageOpenAIDeveloperMessageParamContentListOpenAIChatCompletionContentPartTextParam(BaseModel):
246-
"""Text content part for OpenAI-compatible chat completion messages."""
247-
248-
text: str
249-
"""The text content of the message."""
250-
251-
type: Optional[Literal["text"]] = None
252-
"""Must be 'text' to identify this as text content."""
68+
class ChoiceMessage(BaseModel):
69+
"""The message from the model."""
25370

71+
annotations: Optional[List[Dict[str, object]]] = None
72+
"""Annotations for the message, when applicable."""
25473

255-
class ChoiceMessageOpenAIDeveloperMessageParam(BaseModel):
256-
"""A message from the developer in an OpenAI-compatible chat completion request."""
74+
audio: Optional[Dict[str, object]] = None
75+
"""Audio response data when using audio output modality."""
25776

258-
content: Union[
259-
str, List[ChoiceMessageOpenAIDeveloperMessageParamContentListOpenAIChatCompletionContentPartTextParam]
260-
]
261-
"""The content of the developer message."""
77+
content: Optional[str] = None
78+
"""The content of the message."""
26279

263-
name: Optional[str] = None
264-
"""The name of the developer message participant."""
80+
function_call: Optional[ChoiceMessageFunctionCall] = None
81+
"""Deprecated: the name and arguments of a function that should be called."""
26582

266-
role: Optional[Literal["developer"]] = None
267-
"""Must be 'developer' to identify this as a developer message."""
83+
refusal: Optional[str] = None
84+
"""The refusal message generated by the model."""
26885

86+
role: Optional[Literal["assistant"]] = None
87+
"""The role of the message author, always 'assistant' in responses."""
26988

270-
ChoiceMessage: TypeAlias = Annotated[
271-
Union[
272-
ChoiceMessageOpenAIUserMessageParamOutput,
273-
ChoiceMessageOpenAISystemMessageParam,
274-
ChoiceMessageOpenAIAssistantMessageParamOutput,
275-
ChoiceMessageOpenAIToolMessageParam,
276-
ChoiceMessageOpenAIDeveloperMessageParam,
277-
],
278-
PropertyInfo(discriminator="role"),
279-
]
89+
tool_calls: Optional[List[ChoiceMessageToolCall]] = None
90+
"""The tool calls generated by the model."""
28091

28192

28293
class ChoiceLogprobsContentTopLogprob(BaseModel):

0 commit comments

Comments
 (0)