diff --git a/Cargo.lock b/Cargo.lock index 447bf77f..f581047b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -277,7 +277,7 @@ checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "embeddings" -version = "0.1.102" +version = "0.1.103" dependencies = [ "anyhow", "clap", @@ -662,7 +662,7 @@ checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" [[package]] name = "llama-cpp-2" -version = "0.1.102" +version = "0.1.103" dependencies = [ "encoding_rs", "enumflags2", @@ -674,7 +674,7 @@ dependencies = [ [[package]] name = "llama-cpp-sys-2" -version = "0.1.102" +version = "0.1.103" dependencies = [ "bindgen", "cc", @@ -1115,7 +1115,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "simple" -version = "0.1.102" +version = "0.1.103" dependencies = [ "anyhow", "clap", diff --git a/examples/embeddings/Cargo.toml b/examples/embeddings/Cargo.toml index c96551ec..c3c5b533 100644 --- a/examples/embeddings/Cargo.toml +++ b/examples/embeddings/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "embeddings" -version = "0.1.102" +version = "0.1.103" edition = "2021" [dependencies] diff --git a/examples/simple/Cargo.toml b/examples/simple/Cargo.toml index cb5d4e07..98867c57 100644 --- a/examples/simple/Cargo.toml +++ b/examples/simple/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple" -version = "0.1.102" +version = "0.1.103" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/llama-cpp-2/Cargo.toml b/llama-cpp-2/Cargo.toml index d85ca5af..bf52467c 100644 --- a/llama-cpp-2/Cargo.toml +++ b/llama-cpp-2/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "llama-cpp-2" description = "llama.cpp bindings for Rust" -version = "0.1.102" +version = "0.1.103" edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/utilityai/llama-cpp-rs" diff --git a/llama-cpp-2/src/log.rs b/llama-cpp-2/src/log.rs index 1c324b4b..e77f94bb 100644 --- a/llama-cpp-2/src/log.rs +++ b/llama-cpp-2/src/log.rs @@ -142,16 +142,18 @@ impl State { let (meta, fields) = meta_for_level(level); tracing::dispatcher::get_default(|dispatcher| { - dispatcher.event(&tracing::Event::new( - meta, - &meta.fields().value_set(&[ - (&fields.message, Some(&text as &dyn tracing::field::Value)), - ( - &fields.target, - module.as_ref().map(|s| s as &dyn tracing::field::Value), - ), - ]), - )); + if dispatcher.enabled(meta) { + dispatcher.event(&tracing::Event::new( + meta, + &meta.fields().value_set(&[ + (&fields.message, Some(&text as &dyn tracing::field::Value)), + ( + &fields.target, + module.as_ref().map(|s| s as &dyn tracing::field::Value), + ), + ]), + )); + } }); } diff --git a/llama-cpp-2/src/model.rs b/llama-cpp-2/src/model.rs index 9c83a795..69e938c5 100644 --- a/llama-cpp-2/src/model.rs +++ b/llama-cpp-2/src/model.rs @@ -484,6 +484,13 @@ impl LlamaModel { u32::try_from(unsafe { llama_cpp_sys_2::llama_model_n_head(self.model.as_ptr()) }).unwrap() } + /// Returns the number of KV attention heads. + pub fn n_head_kv(&self) -> u32 { + // It's never possible for this to panic because while the API interface is defined as an int32_t, + // the field it's accessing is a uint32_t. + u32::try_from(unsafe { llama_cpp_sys_2::llama_model_n_head_kv(self.model.as_ptr()) }).unwrap() + } + /// Returns the rope type of the model. pub fn rope_type(&self) -> Option { match unsafe { llama_cpp_sys_2::llama_model_rope_type(self.model.as_ptr()) } { diff --git a/llama-cpp-sys-2/Cargo.toml b/llama-cpp-sys-2/Cargo.toml index 0d07eefd..6db13f98 100644 --- a/llama-cpp-sys-2/Cargo.toml +++ b/llama-cpp-sys-2/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "llama-cpp-sys-2" description = "Low Level Bindings to llama.cpp" -version = "0.1.102" +version = "0.1.103" edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/utilityai/llama-cpp-rs" diff --git a/llama-cpp-sys-2/build.rs b/llama-cpp-sys-2/build.rs index 6179ab60..e2a56b38 100644 --- a/llama-cpp-sys-2/build.rs +++ b/llama-cpp-sys-2/build.rs @@ -379,7 +379,7 @@ fn main() { std::fs::rename(&build_info_src,&build_info_target).unwrap_or_else(|move_e| { // Rename may fail if the target directory is on a different filesystem/disk from the source. // Fall back to copy + delete to achieve the same effect in this case. - std::fs::copy(&build_info_src, &build_info_src).unwrap_or_else(|copy_e| { + std::fs::copy(&build_info_src, &build_info_target).unwrap_or_else(|copy_e| { panic!("Failed to rename {build_info_src:?} to {build_info_target:?}. Move failed with {move_e:?} and copy failed with {copy_e:?}"); }); std::fs::remove_file(&build_info_src).unwrap_or_else(|e| { diff --git a/llama-cpp-sys-2/llama.cpp b/llama-cpp-sys-2/llama.cpp index 300907b2..06c2b156 160000 --- a/llama-cpp-sys-2/llama.cpp +++ b/llama-cpp-sys-2/llama.cpp @@ -1 +1 @@ -Subproject commit 300907b2110cc17b4337334dc397e05de2d8f5e0 +Subproject commit 06c2b1561d8b882bc018554591f8c35eb04ad30e