@@ -46,7 +46,7 @@ class CompletionChoice(TypedDict):
4646 text : str
4747 index : int
4848 logprobs : Optional [CompletionLogprobs ]
49- finish_reason : Optional [Literal ["stop" , "length" ]]
49+ finish_reason : Optional [Literal ["stop" , "length" , "content_filter" ]]
5050
5151
5252class CompletionUsage (TypedDict ):
@@ -61,6 +61,7 @@ class CreateCompletionResponse(TypedDict):
6161 created : int
6262 model : str
6363 choices : List [CompletionChoice ]
64+ object : Optional [Literal ["text_completion" ]]
6465 usage : NotRequired [CompletionUsage ]
6566
6667
@@ -69,11 +70,37 @@ class ChatCompletionResponseFunctionCall(TypedDict):
6970 arguments : str
7071
7172
73+ class ChatCompletionResponseMessageFunctionCall (TypedDict ):
74+ arguments : str
75+ name : str
76+
77+
78+ class ChatCompletionResponseMessageAudio (TypedDict ):
79+ id : str
80+ expires_at : int
81+ data : str
82+ transcript : str
83+
84+
85+ class ChatCompletionResponseMessageAnnotationURLCitation (TypedDict ):
86+ end_index : int
87+ start_index : int
88+ url : str
89+ title : str
90+
91+ class ChatCompletionResponseMessageAnnotation (TypedDict ):
92+ type : Literal ["url_citation" ]
93+ url_citation : ChatCompletionResponseMessageAnnotationURLCitation
94+
95+
7296class ChatCompletionResponseMessage (TypedDict ):
7397 content : Optional [str ]
98+ refusal : Optional [str ]
99+ role : Literal ["assistant" ]
74100 tool_calls : NotRequired ["ChatCompletionMessageToolCalls" ]
75- role : Literal ["assistant" , "function" ] # NOTE: "function" may be incorrect here
76- function_call : NotRequired [ChatCompletionResponseFunctionCall ] # DEPRECATED
101+ annotations : NotRequired [List [ChatCompletionResponseMessageAnnotation ]]
102+ function_call : NotRequired [ChatCompletionResponseMessageFunctionCall ] # DEPRECATED
103+ audio : NotRequired [Optional [ChatCompletionResponseMessageAudio ]]
77104
78105
79106class ChatCompletionFunction (TypedDict ):
@@ -137,21 +164,31 @@ class ChatCompletionStreamResponseDeltaFunctionCall(TypedDict):
137164 arguments : str
138165
139166
167+ ChatCompletionRole = Literal [
168+ "developer" ,
169+ "system" ,
170+ "user" ,
171+ "assistant" ,
172+ "tool" ,
173+ "function"
174+ ]
175+
176+
140177class ChatCompletionStreamResponseDelta (TypedDict ):
141178 content : NotRequired [Optional [str ]]
142179 function_call : NotRequired [
143180 Optional [ChatCompletionStreamResponseDeltaFunctionCall ]
144181 ] # DEPRECATED
145182 tool_calls : NotRequired [Optional [List [ChatCompletionMessageToolCallChunk ]]]
146- role : NotRequired [Optional [Literal ["system" , "user" , "assistant" , "tool" ]]]
183+ role : NotRequired [Optional [Literal ["developer" , " system" , "user" , "assistant" , "tool" ]]]
147184
148185
149186class ChatCompletionStreamResponseChoice (TypedDict ):
150187 index : int
151188 delta : Union [
152189 ChatCompletionStreamResponseDelta , ChatCompletionStreamResponseDeltaEmpty
153190 ]
154- finish_reason : Optional [Literal ["stop" , "length" , "tool_calls" , "function_call" ]]
191+ finish_reason : Optional [Literal ["stop" , "length" , "tool_calls" , "content_filter" , " function_call" ]]
155192 logprobs : NotRequired [Optional [ChatCompletionLogprobs ]]
156193
157194
@@ -173,11 +210,16 @@ class ChatCompletionFunctionCallOption(TypedDict):
173210 name : str
174211
175212
213+ class ChatCompletionResponseFormatJSONSchema (TypedDict ):
214+ name : str
215+ description : NotRequired [str ]
216+ schema : NotRequired [Dict [str , Any ]]
217+ strict : NotRequired [Optional [bool ]]
218+
219+
176220class ChatCompletionRequestResponseFormat (TypedDict ):
177- type : Literal ["text" , "json_object" ]
178- schema : NotRequired [
179- JsonType
180- ] # https://docs.endpoints.anyscale.com/guides/json_mode/
221+ type : Literal ["text" , "json_object" , "json_schema" ]
222+ json_schema : NotRequired [ChatCompletionResponseFormatJSONSchema ]
181223
182224
183225class ChatCompletionRequestMessageContentPartText (TypedDict ):
@@ -195,12 +237,45 @@ class ChatCompletionRequestMessageContentPartImage(TypedDict):
195237 image_url : Union [str , ChatCompletionRequestMessageContentPartImageImageUrl ]
196238
197239
240+ class ChatCompletionRequestMessageContentPartInputAudioData (TypedDict ):
241+ data : str
242+ format : Literal ["wav" , "mp3" ]
243+
244+
245+ class ChatCompletionRequestMessageContentPartAudio (TypedDict ):
246+ type : Literal ["input_audio" ]
247+ input_audio : ChatCompletionRequestMessageContentPartInputAudioData
248+
249+
250+ class ChatCompletionRequestMessageContentPartFileData (TypedDict ):
251+ filename : NotRequired [str ]
252+ file_data : NotRequired [str ]
253+ file_id : NotRequired [str ]
254+
255+
256+ class ChatCompletionRequestMessageContentPartFile (TypedDict ):
257+ type : Literal ["file" ]
258+ file : ChatCompletionRequestMessageContentPartFileData
259+
260+
261+ class ChatCompletionRequestMessageContentPartRefusal (TypedDict ):
262+ type : Literal ["refusal" ]
263+ refusal : str
264+
265+
198266ChatCompletionRequestMessageContentPart = Union [
199267 ChatCompletionRequestMessageContentPartText ,
200268 ChatCompletionRequestMessageContentPartImage ,
269+ ChatCompletionRequestMessageContentPartAudio ,
270+ ChatCompletionRequestMessageContentPartFile ,
201271]
202272
203273
274+ class ChatCompletionRequestDeveloperMessage (TypedDict ):
275+ role : Literal ["developer" ]
276+ content : Optional [str ]
277+
278+
204279class ChatCompletionRequestSystemMessage (TypedDict ):
205280 role : Literal ["system" ]
206281 content : Optional [str ]
@@ -252,6 +327,7 @@ class ChatCompletionRequestFunctionMessage(TypedDict):
252327
253328
254329ChatCompletionRequestMessage = Union [
330+ ChatCompletionRequestDeveloperMessage ,
255331 ChatCompletionRequestSystemMessage ,
256332 ChatCompletionRequestUserMessage ,
257333 ChatCompletionRequestAssistantMessage ,
0 commit comments