feat: match local model directory to MODEL_SPEC.md (#800)
parent
b8325bd8ab
commit
d41942975d
|
|
@ -58,11 +58,18 @@ impl ModelRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_model_dir(&self, name: &str) -> PathBuf {
|
||||||
|
models_dir().join(&self.name).join(name)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_model_path(&self, name: &str) -> PathBuf {
|
pub fn get_model_path(&self, name: &str) -> PathBuf {
|
||||||
models_dir()
|
self.get_model_dir(name).join(GGML_MODEL_RELATIVE_PATH)
|
||||||
.join(&self.name)
|
}
|
||||||
.join(name)
|
|
||||||
.join(GGML_MODEL_RELATIVE_PATH)
|
pub fn save_model_info(&self, name: &str) {
|
||||||
|
let model_info = self.get_model_info(name);
|
||||||
|
let path = self.get_model_dir(name).join("tabby.json");
|
||||||
|
serdeconv::to_json_file(model_info, path).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_model_info(&self, name: &str) -> &ModelInfo {
|
pub fn get_model_info(&self, name: &str) -> &ModelInfo {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ async fn download_model_impl(
|
||||||
prefer_local_file: bool,
|
prefer_local_file: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let model_info = registry.get_model_info(name);
|
let model_info = registry.get_model_info(name);
|
||||||
|
registry.save_model_info(name);
|
||||||
|
|
||||||
let model_path = registry.get_model_path(name);
|
let model_path = registry.get_model_path(name);
|
||||||
if model_path.exists() {
|
if model_path.exists() {
|
||||||
if !prefer_local_file {
|
if !prefer_local_file {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue