Skip to content

Commit

Permalink
handle request failure
Browse files Browse the repository at this point in the history
Signed-off-by: pandyamarut <[email protected]>
  • Loading branch information
pandyamarut committed Dec 9, 2024
1 parent 4ee8595 commit 4ec95fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ async def handler(job):
engine = OpenAIvLLMEngine if job_input.openai_route else vllm_engine
results_generator = engine.generate(job_input)
async for batch in results_generator:
yield batch
# If there's any kind of error in the batch, format it
if isinstance(batch, dict) and 'error' in batch:
yield {"error": str(batch)}
else:
yield batch
except Exception as e:
yield {"error": str(e)}
return
Expand Down

0 comments on commit 4ec95fe

Please sign in to comment.