[Security] Reject non-finite temperature and repetition_penalty values (#45116)
Signed-off-by: jperezde <jperezde@redhat.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import copy
|
||||
import json as json_mod
|
||||
import math
|
||||
from dataclasses import field
|
||||
from enum import Enum, IntEnum
|
||||
from functools import cached_property
|
||||
@@ -503,11 +504,22 @@ class SamplingParams(
|
||||
raise ValueError(
|
||||
f"frequency_penalty must be in [-2, 2], got {self.frequency_penalty}."
|
||||
)
|
||||
if not math.isfinite(self.repetition_penalty):
|
||||
raise ValueError(
|
||||
"repetition_penalty must be a finite number, "
|
||||
f"got {self.repetition_penalty}."
|
||||
)
|
||||
if self.repetition_penalty <= 0.0:
|
||||
raise ValueError(
|
||||
"repetition_penalty must be greater than zero, got "
|
||||
f"{self.repetition_penalty}."
|
||||
)
|
||||
if not math.isfinite(self.temperature):
|
||||
raise VLLMValidationError(
|
||||
f"temperature must be a finite number, got {self.temperature}.",
|
||||
parameter="temperature",
|
||||
value=self.temperature,
|
||||
)
|
||||
if self.temperature < 0.0:
|
||||
raise VLLMValidationError(
|
||||
f"temperature must be non-negative, got {self.temperature}.",
|
||||
|
||||
Reference in New Issue
Block a user