diff --git a/.changes/unreleased/Fixed and Improvements-20241126-151903.yaml b/.changes/unreleased/Fixed and Improvements-20241126-151903.yaml new file mode 100644 index 000000000000..2c1b320ac64b --- /dev/null +++ b/.changes/unreleased/Fixed and Improvements-20241126-151903.yaml @@ -0,0 +1,3 @@ +kind: Fixed and Improvements +body: Fixed a panic that occurred when specifying a local model ([#3464](https://github.com/TabbyML/tabby/issues/3464)) +time: 2024-11-26T15:19:03.863207+08:00 diff --git a/crates/llama-cpp-server/src/lib.rs b/crates/llama-cpp-server/src/lib.rs index 9b9bcb18db55..ef1ba84804d4 100644 --- a/crates/llama-cpp-server/src/lib.rs +++ b/crates/llama-cpp-server/src/lib.rs @@ -10,7 +10,7 @@ use serde::Deserialize; use supervisor::LlamaCppSupervisor; use tabby_common::{ config::{HttpModelConfigBuilder, LocalModelConfig, ModelConfig}, - registry::{parse_model_id, ModelRegistry}, + registry::{parse_model_id, ModelRegistry, GGML_MODEL_PARTITIONED_PREFIX}, }; use tabby_inference::{ChatCompletionStream, CompletionOptions, CompletionStream, Embedding}; @@ -277,10 +277,20 @@ pub async fn create_embedding(config: &ModelConfig) -> Arc { } async fn resolve_model_path(model_id: &str) -> String { - let (registry, name) = parse_model_id(model_id); - let registry = ModelRegistry::new(registry).await; - let path = registry.get_model_entry_path(name); - path.unwrap().display().to_string() + let path = PathBuf::from(model_id); + let path = if path.exists() { + path.join("ggml").join(format!( + "{}00001.gguf", + GGML_MODEL_PARTITIONED_PREFIX.to_owned() + )) + } else { + let (registry, name) = parse_model_id(model_id); + let registry = ModelRegistry::new(registry).await; + registry + .get_model_entry_path(name) + .expect("Model not found") + }; + path.display().to_string() } #[derive(Deserialize)]