Skip to content

Commit

Permalink
More precise error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkLight1337 committed Oct 29, 2024
1 parent f5e72ff commit 9cd1ac3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions vllm/entrypoints/openai/serving_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ async def chat_completion_full_generator(
final_res = res
except asyncio.CancelledError:
return self.create_error_response("Client disconnected")
except ValueError as e:
# TODO: Use a vllm-specific Validation Error
return self.create_error_response(str(e))

assert final_res is not None

Expand Down
8 changes: 6 additions & 2 deletions vllm/entrypoints/openai/serving_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ async def create_completion(
try:
async for i, res in result_generator:
final_res_batch[i] = res
except asyncio.CancelledError:
return self.create_error_response("Client disconnected")
except ValueError as e:
# TODO: Use a vllm-specific Validation Error
return self.create_error_response(str(e))

try:
for i, final_res in enumerate(final_res_batch):
assert final_res is not None

Expand All @@ -211,8 +217,6 @@ async def create_completion(
tokenizer,
request_metadata,
)
except asyncio.CancelledError:
return self.create_error_response("Client disconnected")
except ValueError as e:
# TODO: Use a vllm-specific Validation Error
return self.create_error_response(str(e))
Expand Down
5 changes: 3 additions & 2 deletions vllm/entrypoints/openai/serving_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ async def create_embedding(
try:
async for i, res in result_generator:
final_res_batch[i] = res
except asyncio.CancelledError:
return self.create_error_response("Client disconnected")

try:
for final_res in final_res_batch:
assert final_res is not None

Expand All @@ -235,8 +238,6 @@ async def create_embedding(
response = request_output_to_embedding_response(
final_res_batch_checked, request_id, created_time, model_name,
encoding_format)
except asyncio.CancelledError:
return self.create_error_response("Client disconnected")
except ValueError as e:
# TODO: Use a vllm-specific Validation Error
return self.create_error_response(str(e))
Expand Down

0 comments on commit 9cd1ac3

Please sign in to comment.