[Frontend] Require cache_salt to be non-empty via schema (#50816)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
@@ -452,6 +452,7 @@ class ChatCompletionRequest(OpenAIBaseModel):
|
|||||||
|
|
||||||
cache_salt: str | None = Field(
|
cache_salt: str | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
|
min_length=1,
|
||||||
description=(
|
description=(
|
||||||
"If specified, the prefix cache will be salted with the provided "
|
"If specified, the prefix cache will be salted with the provided "
|
||||||
"string to prevent an attacker to guess prompts in multi-user "
|
"string to prevent an attacker to guess prompts in multi-user "
|
||||||
@@ -968,18 +969,6 @@ class ChatCompletionRequest(OpenAIBaseModel):
|
|||||||
)
|
)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@model_validator(mode="before")
|
|
||||||
@classmethod
|
|
||||||
def check_cache_salt_support(cls, data):
|
|
||||||
if data.get("cache_salt") is not None and (
|
|
||||||
not isinstance(data["cache_salt"], str) or not data["cache_salt"]
|
|
||||||
):
|
|
||||||
raise VLLMValidationError(
|
|
||||||
"Parameter 'cache_salt' must be a non-empty string if provided.",
|
|
||||||
parameter="cache_salt",
|
|
||||||
)
|
|
||||||
return data
|
|
||||||
|
|
||||||
@model_validator(mode="before")
|
@model_validator(mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_system_message_content_type(cls, data):
|
def check_system_message_content_type(cls, data):
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ class CompletionRequest(OpenAIBaseModel):
|
|||||||
|
|
||||||
cache_salt: str | None = Field(
|
cache_salt: str | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
|
min_length=1,
|
||||||
description=(
|
description=(
|
||||||
"If specified, the prefix cache will be salted with the provided "
|
"If specified, the prefix cache will be salted with the provided "
|
||||||
"string to prevent an attacker to guess prompts in multi-user "
|
"string to prevent an attacker to guess prompts in multi-user "
|
||||||
@@ -575,18 +576,6 @@ class CompletionRequest(OpenAIBaseModel):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@model_validator(mode="before")
|
|
||||||
@classmethod
|
|
||||||
def check_cache_salt_support(cls, data):
|
|
||||||
if data.get("cache_salt") is not None and (
|
|
||||||
not isinstance(data["cache_salt"], str) or not data["cache_salt"]
|
|
||||||
):
|
|
||||||
raise VLLMValidationError(
|
|
||||||
"Parameter 'cache_salt' must be a non-empty string if provided.",
|
|
||||||
parameter="cache_salt",
|
|
||||||
)
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
class CompletionLogProbs(OpenAIBaseModel):
|
class CompletionLogProbs(OpenAIBaseModel):
|
||||||
text_offset: list[int] = Field(default_factory=list)
|
text_offset: list[int] = Field(default_factory=list)
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ class ResponsesRequest(OpenAIBaseModel):
|
|||||||
)
|
)
|
||||||
cache_salt: str | None = Field(
|
cache_salt: str | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
|
min_length=1,
|
||||||
description=(
|
description=(
|
||||||
"If specified, the prefix cache will be salted with the provided "
|
"If specified, the prefix cache will be salted with the provided "
|
||||||
"string to prevent an attacker to guess prompts in multi-user "
|
"string to prevent an attacker to guess prompts in multi-user "
|
||||||
@@ -476,18 +477,6 @@ class ResponsesRequest(OpenAIBaseModel):
|
|||||||
)
|
)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@model_validator(mode="before")
|
|
||||||
@classmethod
|
|
||||||
def check_cache_salt_support(cls, data):
|
|
||||||
if data.get("cache_salt") is not None and (
|
|
||||||
not isinstance(data["cache_salt"], str) or not data["cache_salt"]
|
|
||||||
):
|
|
||||||
raise VLLMValidationError(
|
|
||||||
"Parameter 'cache_salt' must be a non-empty string if provided.",
|
|
||||||
parameter="cache_salt",
|
|
||||||
)
|
|
||||||
return data
|
|
||||||
|
|
||||||
@model_validator(mode="before")
|
@model_validator(mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def input_item_parsing(cls, data):
|
def input_item_parsing(cls, data):
|
||||||
|
|||||||
@@ -82,21 +82,6 @@ class PoolingBasicRequestMixin(OpenAIBaseModel):
|
|||||||
)
|
)
|
||||||
# --8<-- [end:pooling-common-extra-params]
|
# --8<-- [end:pooling-common-extra-params]
|
||||||
|
|
||||||
@model_validator(mode="before")
|
|
||||||
@classmethod
|
|
||||||
def check_cache_salt_support(cls, data):
|
|
||||||
if not isinstance(data, dict):
|
|
||||||
return data
|
|
||||||
|
|
||||||
if data.get("cache_salt") is not None and (
|
|
||||||
not isinstance(data["cache_salt"], str) or not data["cache_salt"]
|
|
||||||
):
|
|
||||||
raise VLLMValidationError(
|
|
||||||
"Parameter 'cache_salt' must be a non-empty string if provided.",
|
|
||||||
parameter="cache_salt",
|
|
||||||
)
|
|
||||||
return data
|
|
||||||
|
|
||||||
def _build_pooling_tok_params(
|
def _build_pooling_tok_params(
|
||||||
self,
|
self,
|
||||||
model_config: ModelConfig,
|
model_config: ModelConfig,
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ class GenerateRequest(BaseModel):
|
|||||||
stream_options: StreamOptions | None = None
|
stream_options: StreamOptions | None = None
|
||||||
cache_salt: str | None = Field(
|
cache_salt: str | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
|
min_length=1,
|
||||||
description=(
|
description=(
|
||||||
"If specified, the prefix cache will be salted with the provided "
|
"If specified, the prefix cache will be salted with the provided "
|
||||||
"string to prevent an attacker to guess prompts in multi-user "
|
"string to prevent an attacker to guess prompts in multi-user "
|
||||||
|
|||||||
Reference in New Issue
Block a user