Skip to content

Commit

Permalink
feat: support ModelScope for model registry downloading (TabbyML#477)
Browse files Browse the repository at this point in the history
* feat: update cache info file after each file got downloaded

* refactor: extract Downloader for model downloading logic

* refactor: extract HuggingFaceRegistry

* refactor: extract serde_json to workspace dependency

* feat: add ModelScopeRegistry

* refactor: extract registry to its sub dir.

* feat: add scripts to mirror hf model to modelscope
  • Loading branch information
wsxiaoys authored Sep 26, 2023
1 parent f75a50d commit d42942c
Show file tree
Hide file tree
Showing 15 changed files with 379 additions and 132 deletions.
73 changes: 70 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ homepage = "https://github.com/TabbyML/tabby"
[workspace.dependencies]
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
serdeconv = "0.4.1"
tokio = "1.28"
tokio-util = "0.7"
Expand Down
2 changes: 1 addition & 1 deletion crates/http-api-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
async-trait.workspace = true
reqwest = { workspace = true, features = ["json"] }
serde = { workspace = true, features = ["derive"] }
serde_json = "1.0.105"
serde_json = { workspace = true }
tabby-inference = { version = "0.1.0", path = "../tabby-inference" }

[dev-dependencies]
Expand Down
4 changes: 4 additions & 0 deletions crates/tabby-download/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ serde = { workspace = true }
serdeconv = { workspace = true }
tracing = { workspace = true }
tokio-retry = "0.3.0"
urlencoding = "2.1.3"
serde_json = { workspace = true }
cached = { version = "0.46.0", features = ["async", "proc_macro"] }
async-trait = { workspace = true }
11 changes: 1 addition & 10 deletions crates/tabby-download/src/cache_info.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashMap, fs, path::Path};

use anyhow::{anyhow, Result};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use tabby_common::path::ModelDir;

Expand Down Expand Up @@ -33,15 +33,6 @@ impl CacheInfo {
self.etags.get(path).map(|x| x.as_str())
}

pub fn remote_cache_key(res: &reqwest::Response) -> Result<&str> {
let key = res
.headers()
.get("etag")
.ok_or(anyhow!("etag key missing"))?
.to_str()?;
Ok(key)
}

pub async fn set_local_cache_key(&mut self, path: &str, cache_key: &str) {
self.etags.insert(path.to_string(), cache_key.to_string());
}
Expand Down
Loading

0 comments on commit d42942c

Please sign in to comment.