Skip to content

Commit

Permalink
Fix side effect of #1995 (#2033)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllentDan authored Jul 16, 2024
1 parent 9f3e748 commit 419f765
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lmdeploy/serve/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ async def check_request(request) -> Optional[JSONResponse]:
return create_error_response(
HTTPStatus.BAD_REQUEST,
f'The temperature `{request.temperature}` must be in [0, 2]')
if hasattr(request,
'session_id') and VariableInterface.async_engine.id2step.get(
str(request.session_id), 0) != 0:
return create_error_response(
HTTPStatus.BAD_REQUEST,
f'The session_id `{request.session_id}` is occupied.')
return


Expand Down Expand Up @@ -428,6 +422,11 @@ async def chat_completions_v1(request: ChatCompletionRequest,
error_check_ret = await check_request(request)
if error_check_ret is not None:
return error_check_ret
if VariableInterface.async_engine.id2step.get(str(request.session_id),
0) != 0:
return create_error_response(
HTTPStatus.BAD_REQUEST,
f'The session_id `{request.session_id}` is occupied.')

model_name = request.model
adapter_name = None
Expand Down Expand Up @@ -798,6 +797,11 @@ async def completions_v1(request: CompletionRequest,
error_check_ret = await check_request(request)
if error_check_ret is not None:
return error_check_ret
if VariableInterface.async_engine.id2step.get(str(request.session_id),
0) != 0:
return create_error_response(
HTTPStatus.BAD_REQUEST,
f'The session_id `{request.session_id}` is occupied.')

model_name = request.model
adapter_name = None
Expand Down

0 comments on commit 419f765

Please sign in to comment.