Skip to content

Commit

Permalink
fix: should check local model before resolving model id (#3470)
Browse files Browse the repository at this point in the history
* fix: should check local model before resolving model id

* chore: add change log

* chore: add github id for change log
  • Loading branch information
zwpaper authored Nov 26, 2024
1 parent 53f4206 commit b6b8d60
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
20 changes: 15 additions & 5 deletions crates/llama-cpp-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -277,10 +277,20 @@ pub async fn create_embedding(config: &ModelConfig) -> Arc<dyn Embedding> {
}

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)]
Expand Down

0 comments on commit b6b8d60

Please sign in to comment.