Skip to content

Commit

Permalink
feat(core): add TABBY_MODEL_CACHE_ROOT to allow individually set tabb… (
Browse files Browse the repository at this point in the history
#1121)

* feat(core): add TABBY_MODEL_CACHE_ROOT to allow individually set tabby model cache dir

* docs: update changelog

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
wsxiaoys and autofix-ci[bot] authored Dec 26, 2023
1 parent 49e86c4 commit 3f1fefb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Add windows cpu binary distribution.
* Add linux rocm (AMD GPU) binary distribution.
* Fix cached permanent redirection on certain browsers(e.g chrome) when `--webserver` is not enabled.
* Add environment variable `TABBY_MODEL_CACHE_ROOT` to override models cache directory individually.

# v0.7.0 (12/15/2023)

Expand Down
8 changes: 7 additions & 1 deletion crates/tabby-common/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ lazy_static! {
Err(_) => home::home_dir().unwrap().join(".tabby"),
}))
};
static ref TABBY_MODEL_CACHE_ROOT: Option<PathBuf> =
env::var("TABBY_MODEL_CACHE_ROOT").ok().map(PathBuf::from);
}

#[cfg(feature = "testutils")]
Expand Down Expand Up @@ -48,7 +50,11 @@ pub fn dataset_dir() -> PathBuf {
}

pub fn models_dir() -> PathBuf {
tabby_root().join("models")
if let Some(cache_root) = &*TABBY_MODEL_CACHE_ROOT {
cache_root.clone()
} else {
tabby_root().join("models")
}
}

pub fn events_dir() -> PathBuf {
Expand Down

0 comments on commit 3f1fefb

Please sign in to comment.