@@ -197,7 +197,36 @@ async def authenticate(
197
197
198
198
199
199
@router .post (
200
- "/v1/completions" , summary = "Completion" , dependencies = [Depends (authenticate )]
200
+ "/v1/completions" ,
201
+ summary = "Completion" ,
202
+ dependencies = [Depends (authenticate )],
203
+ response_model = Union [
204
+ llama_cpp .CreateCompletionResponse ,
205
+ str ,
206
+ ],
207
+ responses = {
208
+ "200" : {
209
+ "description" : "Successful Response" ,
210
+ "content" : {
211
+ "application/json" : {
212
+ "schema" : {
213
+ "anyOf" : [
214
+ {"$ref" : "#/components/schemas/CreateCompletionResponse" }
215
+ ],
216
+ "title" : "Completion response, when stream=False" ,
217
+ }
218
+ },
219
+ "text/event-stream" :{
220
+ "schema" : {
221
+ "type" : "string" ,
222
+ "title" : "Server Side Streaming response, when stream=True. " +
223
+ "See SSE format: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format" , # noqa: E501
224
+ "example" : """data: {... see CreateCompletionResponse ...} \\ n\\ n data: ... \\ n\\ n ... data: [DONE]"""
225
+ }
226
+ }
227
+ },
228
+ }
229
+ },
201
230
)
202
231
@router .post (
203
232
"/v1/engines/copilot-codex/completions" ,
@@ -280,7 +309,33 @@ async def create_embedding(
280
309
281
310
282
311
@router .post (
283
- "/v1/chat/completions" , summary = "Chat" , dependencies = [Depends (authenticate )]
312
+ "/v1/chat/completions" , summary = "Chat" , dependencies = [Depends (authenticate )],
313
+ response_model = Union [
314
+ llama_cpp .ChatCompletion , str
315
+ ],
316
+ responses = {
317
+ "200" : {
318
+ "description" : "Successful Response" ,
319
+ "content" : {
320
+ "application/json" : {
321
+ "schema" : {
322
+ "anyOf" : [
323
+ {"$ref" : "#/components/schemas/CreateChatCompletionResponse" }
324
+ ],
325
+ "title" : "Completion response, when stream=False" ,
326
+ }
327
+ },
328
+ "text/event-stream" :{
329
+ "schema" : {
330
+ "type" : "string" ,
331
+ "title" : "Server Side Streaming response, when stream=True" +
332
+ "See SSE format: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format" , # noqa: E501
333
+ "example" : """data: {... see CreateChatCompletionResponse ...} \\ n\\ n data: ... \\ n\\ n ... data: [DONE]"""
334
+ }
335
+ }
336
+ },
337
+ }
338
+ },
284
339
)
285
340
async def create_chat_completion (
286
341
request : Request ,
0 commit comments