We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f81636b + efbf57a commit 9e5658eCopy full SHA for 9e5658e
llama-cpp-2/src/model.rs
@@ -1,5 +1,6 @@
1
//! A safe wrapper around `llama_model`.
2
use std::ffi::CString;
3
+use std::ffi::CStr;
4
use std::num::NonZeroU16;
5
use std::os::raw::c_int;
6
use std::path::Path;
@@ -549,7 +550,7 @@ impl LlamaModel {
549
550
if res > buff.len() as i32 {
551
return Err(ApplyChatTemplateError::BuffSizeError);
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())
554
}?;
555
Ok(formatted_chat)
556
0 commit comments