Skip to content

Commit 045c5f2

Browse files
authored
Merge pull request #683 from nobodywho-ooo/fix-chat-template-initialization
Use CString::new instead of CString::from_str to init chat template
2 parents 375eb20 + 1d49ebf commit 045c5f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llama-cpp-2/src/model.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::num::NonZeroU16;
44
use std::os::raw::c_int;
55
use std::path::Path;
66
use std::ptr::NonNull;
7-
use std::str::{FromStr, Utf8Error};
7+
use std::str::Utf8Error;
88

99
use crate::context::params::LlamaContextParams;
1010
use crate::context::LlamaContext;
@@ -47,7 +47,7 @@ impl LlamaChatTemplate {
4747
/// Create a new template from a string. This can either be the name of a llama.cpp [chat template](https://github.com/ggerganov/llama.cpp/blob/8a8c4ceb6050bd9392609114ca56ae6d26f5b8f5/src/llama-chat.cpp#L27-L61)
4848
/// like "chatml" or "llama3" or an actual Jinja template for llama.cpp to interpret.
4949
pub fn new(template: &str) -> Result<Self, std::ffi::NulError> {
50-
Ok(Self(CString::from_str(template)?))
50+
Ok(Self(CString::new(template)?))
5151
}
5252

5353
/// Accesses the template as a c string reference.

0 commit comments

Comments
 (0)