[BugFix]: properly catch templating error when preprocess input (#13976)

Signed-off-by: Guillaume Calmettes <gcalmettes@scaleway.com>
This commit is contained in:
Guillaume Calmettes
2025-03-14 08:58:34 -04:00
committed by GitHub
parent ab93f1360f
commit fd8e055ffb
5 changed files with 37 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ from collections.abc import AsyncGenerator, AsyncIterator
from collections.abc import Sequence as GenericSequence
from typing import Callable, Final, Optional, Union
import jinja2
from fastapi import Request
from vllm.config import ModelConfig
@@ -199,6 +200,15 @@ class OpenAIServingChat(OpenAIServing):
except ValueError as e:
logger.exception("Error in preprocessing prompt inputs")
return self.create_error_response(str(e))
except TypeError as e:
logger.exception("Error in preprocessing prompt inputs")
return self.create_error_response(str(e))
except RuntimeError as e:
logger.exception("Error in preprocessing prompt inputs")
return self.create_error_response(str(e))
except jinja2.TemplateError as e:
logger.exception("Error in preprocessing prompt inputs")
return self.create_error_response(str(e))
request_id = "chatcmpl-" \
f"{self._base_request_id(raw_request, request.request_id)}"