mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-13 04:13:35 +08:00
Fix: restrict max_retries as non-negative integer (#18051)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
Reference in New Issue
Block a user