Skip to content

Commit

Permalink
Simplify collapse_whitespace (#8293)
Browse files Browse the repository at this point in the history
Signed-off-by: harupy <hkawamura0130@gmail.com>
  • Loading branch information
harupy committed Apr 21, 2023
1 parent 3e9f5c2 commit 9406176
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions mlflow/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,6 @@ def _strip_input_from_response_in_instruction_pipelines(
Parse the output from instruction pipelines to conform with other text generator
pipeline types and remove line feed characters and other confusing outputs
"""
replacements = {"\n+": " ", "\\s+": " "}

def extract_response_data(data_out):
if all(isinstance(x, dict) for x in data_out):
Expand Down Expand Up @@ -1675,8 +1674,7 @@ def trim_input(data_in, data_out):
# If the user has indicated to remove newlines and extra spaces from the generated
# text, replace them with a single space.
if collapse_whitespace:
for to_replace, replace in replacements.items():
data_out = re.sub(to_replace, replace, data_out).strip()
data_out = re.sub(r"\s+", " ", data_out).strip()
return data_out
else:
return data_out
Expand Down

0 comments on commit 9406176

Please sign in to comment.