fixed truncation error in fake language model
This commit is contained in:
parent
3447a9478c
commit
ca82ec8e8e
4 changed files with 10 additions and 3 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue