From 56581c7132ede99610067006032e0aa970a1cbb3 Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Tue, 26 Nov 2024 15:12:31 +0800 Subject: [PATCH 1/3] fix: should check local model before resolving model id --- crates/llama-cpp-server/src/lib.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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)] From d087c96c27092f82d12fd3ca0e7171d996852459 Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Tue, 26 Nov 2024 15:19:25 +0800 Subject: [PATCH 2/3] chore: add change log --- .../unreleased/Fixed and Improvements-20241126-151903.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changes/unreleased/Fixed and Improvements-20241126-151903.yaml 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..8cbf4f1c9d8d --- /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 +time: 2024-11-26T15:19:03.863207+08:00 From 42b03abdd6c0db3da522237bd4f81f66dbcd2faa Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Tue, 26 Nov 2024 15:24:48 +0800 Subject: [PATCH 3/3] chore: add github id for change log --- .changes/unreleased/Fixed and Improvements-20241126-151903.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/unreleased/Fixed and Improvements-20241126-151903.yaml b/.changes/unreleased/Fixed and Improvements-20241126-151903.yaml index 8cbf4f1c9d8d..2c1b320ac64b 100644 --- a/.changes/unreleased/Fixed and Improvements-20241126-151903.yaml +++ b/.changes/unreleased/Fixed and Improvements-20241126-151903.yaml @@ -1,3 +1,3 @@ kind: Fixed and Improvements -body: Fixed a panic that occurred when specifying a local model +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