fix: support local model path (#165)
parent
418558c05d
commit
8956056120
|
|
@ -67,9 +67,7 @@ pub struct CompletionState {
|
|||
|
||||
impl CompletionState {
|
||||
pub fn new(args: &crate::serve::ServeArgs) -> Self {
|
||||
let home = std::env::var("HOME").unwrap();
|
||||
let tabby_root = format!("{}/.tabby", home);
|
||||
let model_dir = Path::new(&tabby_root).join("models").join(&args.model);
|
||||
let model_dir = get_model_dir(&args.model);
|
||||
let metadata = read_metadata(&model_dir);
|
||||
|
||||
let device = format!("{}", args.device);
|
||||
|
|
@ -87,6 +85,16 @@ impl CompletionState {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_model_dir(model: &str) -> std::path::PathBuf {
|
||||
if Path::new(model).exists() {
|
||||
Path::new(model).to_path_buf()
|
||||
} else {
|
||||
let home = std::env::var("HOME").unwrap();
|
||||
let tabby_root = format!("{}/.tabby", home);
|
||||
Path::new(&tabby_root).join("models").join(model)
|
||||
}
|
||||
}
|
||||
|
||||
fn timestamp() -> u64 {
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
let start = SystemTime::now();
|
||||
|
|
|
|||
Loading…
Reference in New Issue