"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "b993b66cfb4367f62908492f399ddfbd638fbeeb"
Unverified Commit 9f58becc authored by David del Río Medina's avatar David del Río Medina Committed by GitHub
Browse files

Replace assert statements with exceptions (#13871)

parent 155b2300
...@@ -1896,10 +1896,10 @@ class ModelOutput(OrderedDict): ...@@ -1896,10 +1896,10 @@ class ModelOutput(OrderedDict):
class_fields = fields(self) class_fields = fields(self)
# Safety and consistency checks # Safety and consistency checks
assert len(class_fields), f"{self.__class__.__name__} has no fields." if not len(class_fields):
assert all( raise ValueError(f"{self.__class__.__name__} has no fields.")
field.default is None for field in class_fields[1:] if not all(field.default is None for field in class_fields[1:]):
), f"{self.__class__.__name__} should not have more than one required field." raise ValueError(f"{self.__class__.__name__} should not have more than one required field.")
first_field = getattr(self, class_fields[0].name) first_field = getattr(self, class_fields[0].name)
other_fields_are_none = all(getattr(self, field.name) is None for field in class_fields[1:]) other_fields_are_none = all(getattr(self, field.name) is None for field in class_fields[1:])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment