Fix: restrict max_retries as non-negative integer (#18051)

This commit is contained in:
Wang Qi
2026-08-10 20:02:24 +08:00
committed by GitHub
parent df32ffbe57
commit b978f94fa6
2 changed files with 9 additions and 0 deletions

View File

@@ -260,6 +260,11 @@ class ComponentParamBase(ABC):
if not param:
raise ValueError(description + " does not support empty value.")
@staticmethod
def check_nonnegative_integer(param, description):
if type(param).__name__ not in ["int", "long"] or param < 0:
raise ValueError(description + " {} not supported, should be 0 or positive integer".format(param))
@staticmethod
def check_positive_integer(param, description):
if type(param).__name__ not in ["int", "long"] or param <= 0:

View File

@@ -58,6 +58,10 @@ class LLMParam(ComponentParamBase):
self.check_decimal_float(float(self.top_p), "[Agent] Top P")
self.check_empty(self.llm_id, "[Agent] LLM")
self.check_empty(self.prompts, "[Agent] User prompt")
self.check_nonnegative_integer(self.max_retries, "[Agent] Max retries")
if hasattr(self, "max_rounds"):
self.check_defined_type(self.max_rounds, "[Agent] Max rounds", ["int"])
self.check_nonnegative_number(self.max_rounds, "[Agent] Max rounds")
def gen_conf(self):
conf = {}