feat: match local model directory to MODEL_SPEC.md (#800)

release-fix-intellij-update-support-version-range
Meng Zhang 2023-11-15 19:33:38 -08:00 committed by GitHub
parent b8325bd8ab
commit d41942975d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -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 {
models_dir()
.join(&self.name)
.join(name)
.join(GGML_MODEL_RELATIVE_PATH)
self.get_model_dir(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 {

View File

@ -15,6 +15,8 @@ async fn download_model_impl(
prefer_local_file: bool,
) -> Result<()> {
let model_info = registry.get_model_info(name);
registry.save_model_info(name);
let model_path = registry.get_model_path(name);
if model_path.exists() {
if !prefer_local_file {