diff --git a/Cargo.lock b/Cargo.lock index 324f9a73..b6ec46a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1601,23 +1601,26 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hf-hub" -version = "0.3.2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b780635574b3d92f036890d8373433d6f9fc7abb320ee42a5c25897fc8ed732" +checksum = "cc03dcb0b0a83ae3f3363ec811014ae669f083e4e499c66602f447c4828737a1" dependencies = [ "dirs", "futures", + "http 1.2.0", "indicatif", + "libc", "log", "native-tls", "num_cpus", "rand", - "reqwest 0.11.27", + "reqwest", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.11", "tokio", "ureq", + "windows-sys 0.59.0", ] [[package]] @@ -1774,19 +1777,6 @@ dependencies = [ "tokio-io-timeout", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.32", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-tls" version = "0.6.0" @@ -3525,46 +3515,6 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.32", - "hyper-tls 0.5.0", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration 0.5.1", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - [[package]] name = "reqwest" version = "0.12.12" @@ -3583,7 +3533,7 @@ dependencies = [ "http-body-util", "hyper 1.6.0", "hyper-rustls", - "hyper-tls 0.6.0", + "hyper-tls", "hyper-util", "ipnet", "js-sys", @@ -3595,21 +3545,23 @@ dependencies = [ "pin-project-lite", "quinn", "rustls", - "rustls-pemfile 2.2.0", + "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 1.0.2", - "system-configuration 0.6.1", + "system-configuration", "tokio", "tokio-native-tls", "tokio-rustls", + "tokio-util", "tower 0.5.2", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", "webpki-roots", "windows-registry", @@ -3722,15 +3674,6 @@ dependencies = [ "security-framework 3.2.0", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -4162,17 +4105,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation 0.9.4", - "system-configuration-sys 0.5.0", -] - [[package]] name = "system-configuration" version = "0.6.1" @@ -4181,17 +4113,7 @@ checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags 2.8.0", "core-foundation 0.9.4", - "system-configuration-sys 0.6.0", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", + "system-configuration-sys", ] [[package]] @@ -4354,7 +4276,7 @@ dependencies = [ "opentelemetry-otlp 0.16.0", "opentelemetry_sdk 0.23.0", "prost 0.12.6", - "reqwest 0.12.12", + "reqwest", "serde", "serde_json", "simsimd", @@ -5105,7 +5027,7 @@ dependencies = [ "axum 0.7.9", "mime_guess", "regex", - "reqwest 0.12.12", + "reqwest", "rust-embed", "serde", "serde_json", @@ -5279,6 +5201,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.77" @@ -5547,16 +5482,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "wit-bindgen-rt" version = "0.33.0" diff --git a/Cargo.toml b/Cargo.toml index f44df03c..919b293f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ homepage = "https://github.com/huggingface/text-embeddings-inference" [workspace.dependencies] anyhow = "1.0.75" clap = { version = "4.1", features = ["derive", "env"] } -hf-hub = { version = "0.3.2", features = ["tokio", "online"], default-features = false } +hf-hub = { version = "0.4.2", features = ["tokio"], default-features = false } metrics = "0.23" nohash-hasher = "0.2" num_cpus = "1.16.0" diff --git a/backends/candle/Cargo.toml b/backends/candle/Cargo.toml index f26d213a..777cf6fd 100644 --- a/backends/candle/Cargo.toml +++ b/backends/candle/Cargo.toml @@ -29,7 +29,7 @@ memmap2 = "^0.9" [dev-dependencies] insta = { git = "https://github.com/OlivierDehaene/insta", rev = "f4f98c0410b91fb5a28b10df98e4422955be9c2c", features = ["yaml"] } is_close = "0.1.3" -hf-hub = "0.3.2" +hf-hub = "0.4.2" anyhow = { workspace = true } tokenizers = { workspace = true } serial_test = "2.0.0" diff --git a/backends/candle/tests/common.rs b/backends/candle/tests/common.rs index 0c069a47..febab3b9 100644 --- a/backends/candle/tests/common.rs +++ b/backends/candle/tests/common.rs @@ -113,6 +113,10 @@ pub fn download_artifacts( builder = builder.with_cache_dir(cache_dir.into()); } + if let Ok(origin) = std::env::var("HF_HUB_USER_AGENT_ORIGIN") { + builder = builder.with_user_agent("origin", origin.as_str()); + } + let api = builder.build().unwrap(); let api_repo = if let Some(revision) = revision { api.repo(Repo::with_revision( diff --git a/backends/candle/tests/snapshots/test_gte__snowflake_gte_batch.snap b/backends/candle/tests/snapshots/test_gte__snowflake_gte_batch.snap index b9f3be64..0e72da5a 100644 --- a/backends/candle/tests/snapshots/test_gte__snowflake_gte_batch.snap +++ b/backends/candle/tests/snapshots/test_gte__snowflake_gte_batch.snap @@ -2307,4 +2307,3 @@ expression: embeddings_batch - -0.16524515 - -0.100704014 - 0.3677737 - diff --git a/backends/candle/tests/snapshots/test_gte__snowflake_gte_single.snap b/backends/candle/tests/snapshots/test_gte__snowflake_gte_single.snap index d2791370..6e820abd 100644 --- a/backends/candle/tests/snapshots/test_gte__snowflake_gte_single.snap +++ b/backends/candle/tests/snapshots/test_gte__snowflake_gte_single.snap @@ -771,4 +771,3 @@ expression: embeddings_single - -0.16524515 - -0.100704014 - 0.3677737 - diff --git a/router/src/lib.rs b/router/src/lib.rs index 76cebccc..79ef1ba2 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -78,6 +78,10 @@ pub async fn run( builder = builder.with_cache_dir(cache_dir.into()); } + if let Ok(origin) = std::env::var("HF_HUB_USER_AGENT_ORIGIN") { + builder = builder.with_user_agent("origin", origin.as_str()); + } + let api = builder.build().unwrap(); let api_repo = api.repo(Repo::with_revision( model_id.clone(),