assistant: Normalize line endings for prompts loaded from templates (#16808)
Closes #16804 Similar to #15708, when reading prompts from a template, both Windows and Linux might end up with `CRLF (\r\n)` line endings, which can result in a panic. Release Notes: - N/A
This commit is contained in:
parent
a28700a74d
commit
5ee4c036f9
2 changed files with 11 additions and 2 deletions
|
@ -3041,4 +3041,12 @@ impl LineEnding {
|
|||
text
|
||||
}
|
||||
}
|
||||
|
||||
pub fn normalize_cow(text: Cow<str>) -> Cow<str> {
|
||||
if let Cow::Owned(replaced) = LINE_SEPARATORS_REGEX.replace_all(&text, "\n") {
|
||||
replaced.into()
|
||||
} else {
|
||||
text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue