Adding ValueError when imcompatible parameters are used. (#20729)

This commit is contained in:
Nicolas Patry
2022-12-12 15:39:13 +01:00
committed by GitHub
parent 5ba2dbd9b1
commit 53357e8196
2 changed files with 5 additions and 0 deletions

View File

@@ -130,6 +130,8 @@ class TextGenerationPipeline(Pipeline):
postprocess_params = {}
if return_full_text is not None and return_type is None:
if return_text is not None:
raise ValueError("`return_text` is mutually exclusive with `return_full_text`")
return_type = ReturnType.FULL_TEXT if return_full_text else ReturnType.NEW_TEXT
if return_tensors is not None and return_type is None:
return_type = ReturnType.TENSORS

View File

@@ -201,6 +201,9 @@ class TextGenerationPipelineTests(unittest.TestCase, metaclass=PipelineTestCaseM
],
)
with self.assertRaises(ValueError):
outputs = text_generator("test", return_full_text=True, return_text=True)
# Empty prompt is slighly special
# it requires BOS token to exist.
# Special case for Pegasus which will always append EOS so will