Unverified Commit 29862b88 authored by Nick Hill's avatar Nick Hill Committed by GitHub
Browse files

[Frontend] Adjust try/except blocks in API impl (#10056)


Signed-off-by: default avatarNick Hill <nhill@redhat.com>
parent d3859f18
......@@ -189,13 +189,7 @@ class OpenAIServingCompletion(OpenAIServing):
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
......@@ -217,6 +211,8 @@ class OpenAIServingCompletion(OpenAIServing):
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))
......
......@@ -205,12 +205,8 @@ class OpenAIServingEmbedding(OpenAIServing):
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
assert all(final_res is not None for final_res in final_res_batch)
final_res_batch_checked = cast(List[EmbeddingRequestOutput],
final_res_batch)
......@@ -218,6 +214,8 @@ class OpenAIServingEmbedding(OpenAIServing):
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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment