Skip to content

Commit b52c013

Browse files
authored
Revert: gracefully ignore unsupported OpenAI API parameters (#1261) (#1264)
1 parent eac63be commit b52c013

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

lightllm/server/api_models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing_extensions import deprecated
33
import uuid
44

5-
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
5+
from pydantic import BaseModel, Field, field_validator, model_validator
66
from typing import Any, Dict, List, Optional, Union, Literal, ClassVar
77
from transformers import GenerationConfig
88

@@ -116,7 +116,6 @@ def _normalize_role(cls, v):
116116

117117

118118
class CompletionRequest(BaseModel):
119-
model_config = ConfigDict(extra="ignore")
120119
model: str
121120
# prompt: string or tokens
122121
prompt: Union[str, List[str], List[int], List[List[int]]]
@@ -188,7 +187,6 @@ def apply_loaded_defaults(cls, data: Any):
188187

189188

190189
class ChatCompletionRequest(BaseModel):
191-
model_config = ConfigDict(extra="ignore")
192190
model: str
193191
messages: List[ChatCompletionMessageParam]
194192
function_call: Optional[str] = "none"

lightllm/server/api_openai.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,13 @@ async def chat_completions_impl(request: ChatCompletionRequest, raw_request: Req
180180
from .api_http import g_objs
181181

182182
if request.logit_bias is not None:
183-
logger.debug("Received unsupported parameter 'logit_bias', ignoring")
183+
return create_error_response(
184+
HTTPStatus.BAD_REQUEST,
185+
"The logit_bias parameter is not currently supported",
186+
)
184187

185188
if request.function_call != "none":
186-
logger.debug("Received unsupported parameter 'function_call', ignoring")
189+
return create_error_response(HTTPStatus.BAD_REQUEST, "The function call feature is not supported")
187190

188191
created_time = int(time.time())
189192

@@ -604,7 +607,10 @@ async def completions_impl(request: CompletionRequest, raw_request: Request) ->
604607
from .api_http import g_objs
605608

606609
if request.logit_bias is not None:
607-
logger.debug("Received unsupported parameter 'logit_bias', ignoring")
610+
return create_error_response(
611+
HTTPStatus.BAD_REQUEST,
612+
"The logit_bias parameter is not currently supported",
613+
)
608614

609615
created_time = int(time.time())
610616

@@ -632,7 +638,10 @@ async def completions_impl(request: CompletionRequest, raw_request: Request) ->
632638

633639
# Handle suffix for completion mode
634640
if request.suffix:
635-
logger.debug("Received unsupported parameter 'suffix', ignoring")
641+
return create_error_response(
642+
HTTPStatus.BAD_REQUEST,
643+
"The suffix parameter is not currently supported",
644+
)
636645

637646
# Prepare sampling parameters - same as g_generate_stream_func pattern
638647
sampling_params_dict = {

0 commit comments

Comments
 (0)