fix(api/core/model_runtime/model_providers/__base/large_language_model.py): Add TEXT type checker (#7407)

This commit is contained in:
-LAN- 2024-08-19 18:45:30 +08:00 committed by GitHub
parent bd07e1d2fd
commit 0087afc2e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -792,6 +792,13 @@ if you are not sure about the structure.
if not isinstance(parameter_value, str): if not isinstance(parameter_value, str):
raise ValueError(f"Model Parameter {parameter_name} should be string.") raise ValueError(f"Model Parameter {parameter_name} should be string.")
# validate options
if parameter_rule.options and parameter_value not in parameter_rule.options:
raise ValueError(f"Model Parameter {parameter_name} should be one of {parameter_rule.options}.")
elif parameter_rule.type == ParameterType.TEXT:
if not isinstance(parameter_value, str):
raise ValueError(f"Model Parameter {parameter_name} should be text.")
# validate options # validate options
if parameter_rule.options and parameter_value not in parameter_rule.options: if parameter_rule.options and parameter_value not in parameter_rule.options:
raise ValueError(f"Model Parameter {parameter_name} should be one of {parameter_rule.options}.") raise ValueError(f"Model Parameter {parameter_name} should be one of {parameter_rule.options}.")