should return invalide request for empty prompt (#9315)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
import time
|
||||
from typing import Any, AsyncGenerator, Dict, List, Union
|
||||
from typing import Any, AsyncGenerator, Dict, List, Optional, Union
|
||||
|
||||
from fastapi import Request
|
||||
from fastapi.responses import ORJSONResponse, StreamingResponse
|
||||
@@ -41,6 +41,14 @@ class OpenAIServingCompletion(OpenAIServingBase):
|
||||
def _request_id_prefix(self) -> str:
|
||||
return "cmpl-"
|
||||
|
||||
def _validate_request(self, request: CompletionRequest) -> Optional[str]:
|
||||
"""Validate that the input is valid."""
|
||||
prompt = request.prompt
|
||||
if not prompt or (isinstance(prompt, list) and all(not p for p in prompt)):
|
||||
return "Prompt cannot be empty"
|
||||
|
||||
return None
|
||||
|
||||
def _convert_to_internal_request(
|
||||
self,
|
||||
request: CompletionRequest,
|
||||
|
||||
Reference in New Issue
Block a user