Skip to content

Commit 9e5658e

Browse files
authored
Merge pull request #456 from hjiayz/patch-1
fix bug
2 parents f81636b + efbf57a commit 9e5658e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llama-cpp-2/src/model.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! A safe wrapper around `llama_model`.
22
use std::ffi::CString;
3+
use std::ffi::CStr;
34
use std::num::NonZeroU16;
45
use std::os::raw::c_int;
56
use std::path::Path;
@@ -549,7 +550,7 @@ impl LlamaModel {
549550
if res > buff.len() as i32 {
550551
return Err(ApplyChatTemplateError::BuffSizeError);
551552
}
552-
String::from_utf8(buff.iter().filter(|c| **c > 0).map(|&c| c as u8).collect())
553+
Ok::<String, ApplyChatTemplateError>(CStr::from_ptr(buff.as_mut_ptr()).to_string_lossy().to_string())
553554
}?;
554555
Ok(formatted_chat)
555556
}

0 commit comments

Comments
 (0)