Unverified Commit 0cf3fbeb authored by gongwei-130's avatar gongwei-130 Committed by GitHub
Browse files

should return invalide request for empty prompt (#9315)

parent 2256d62d
import logging import logging
import time 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 import Request
from fastapi.responses import ORJSONResponse, StreamingResponse from fastapi.responses import ORJSONResponse, StreamingResponse
...@@ -41,6 +41,14 @@ class OpenAIServingCompletion(OpenAIServingBase): ...@@ -41,6 +41,14 @@ class OpenAIServingCompletion(OpenAIServingBase):
def _request_id_prefix(self) -> str: def _request_id_prefix(self) -> str:
return "cmpl-" 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( def _convert_to_internal_request(
self, self,
request: CompletionRequest, request: CompletionRequest,
......
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