31
31
TEXT_COMPLETIONS_PATH = "/v1/completions"
32
32
CHAT_COMPLETIONS_PATH = "/v1/chat/completions"
33
33
34
- CompletionEndpointType = Literal ["text_completions" , "chat_completions" ]
35
- EndpointType = Union [Literal ["models" ], CompletionEndpointType ]
36
- CHAT_COMPLETIONS : CompletionEndpointType = "chat_completions"
34
+ EndpointType = Literal ["chat_completions" , "models" , "text_completions" ]
35
+ CHAT_COMPLETIONS : EndpointType = "chat_completions"
37
36
MODELS : EndpointType = "models"
38
- TEXT_COMPLETIONS : CompletionEndpointType = "text_completions"
37
+ TEXT_COMPLETIONS : EndpointType = "text_completions"
39
38
40
39
41
40
@Backend .register ("openai_http" )
@@ -448,7 +447,7 @@ def _extra_body(self, endpoint_type: EndpointType) -> dict[str, Any]:
448
447
449
448
def _completions_payload (
450
449
self ,
451
- endpoint_type : CompletionEndpointType ,
450
+ endpoint_type : EndpointType ,
452
451
orig_kwargs : Optional [dict ],
453
452
max_output_tokens : Optional [int ],
454
453
** kwargs ,
@@ -468,10 +467,8 @@ def _completions_payload(
468
467
self .__class__ .__name__ ,
469
468
max_output_tokens or self .max_output_tokens ,
470
469
)
471
- max_output_key = settings .openai .max_output_key .get (
472
- endpoint_type , "max_tokens"
473
- )
474
- payload [max_output_key ] = max_output_tokens or self .max_output_tokens
470
+ payload ["max_tokens" ] = max_output_tokens or self .max_output_tokens
471
+ payload ["max_completion_tokens" ] = payload ["max_tokens" ]
475
472
476
473
if max_output_tokens :
477
474
# only set stop and ignore_eos if max_output_tokens set at request level
0 commit comments