fixed truncation error in fake language model

This commit is contained in:
KCaverly 2023-10-26 14:05:55 +02:00
parent 3447a9478c
commit ca82ec8e8e
4 changed files with 10 additions and 3 deletions

View file

@ -29,6 +29,10 @@ impl LanguageModel for FakeLanguageModel {
length: usize,
direction: TruncationDirection,
) -> anyhow::Result<String> {
if length > self.count_tokens(content)? {
return anyhow::Ok(content.to_string());
}
anyhow::Ok(match direction {
TruncationDirection::End => content.chars().collect::<Vec<char>>()[..length]
.into_iter()