Personal AI, On Personal Devices
Python
build(deps): upgrade rand and migrate router sampling (#914)
dependabot[bot]97da475de28a
diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex 7aa19d99..0b7f0487 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -1082,7 +1082,7 @@ version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8"dependencies = [- "rand 0.8.5",+ "rand 0.8.8",][[package]]@@ -1199,7 +1199,7 @@ dependencies = ["openjarvis-core","openjarvis-traces","parking_lot",- "rand 0.8.5",+ "rand 0.9.2","regex","rusqlite","serde",@@ -1659,9 +1659,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"[[package]]name = "rand"-version = "0.8.5"+version = "0.8.8"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"+checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"dependencies = ["libc","rand_chacha 0.3.1",diff --git a/rust/Cargo.toml b/rust/Cargo.tomlindex ea994d16..e686e438 100644--- a/rust/Cargo.toml+++ b/rust/Cargo.toml@@ -41,7 +41,7 @@ regex = "1"once_cell = "1"sha2 = "0.11"uuid = { version = "1", features = ["v4"] }-rand = "0.8"+rand = "0.9"parking_lot = "0.12"async-trait = "0.1"pyo3 = { version = "0.29", features = ["extension-module"] }diff --git a/rust/crates/openjarvis-learning/src/bandit.rs b/rust/crates/openjarvis-learning/src/bandit.rsindex 47f67a21..aade61b6 100644--- a/rust/crates/openjarvis-learning/src/bandit.rs+++ b/rust/crates/openjarvis-learning/src/bandit.rs@@ -60,7 +60,7 @@ impl BanditRouterPolicy {fn thompson_sample(&self) -> String {let stats = self.stats.lock();- let mut rng = thread_rng();+ let mut rng = rand::rng();let mut best_model = self.models[0].clone();let mut best_sample = f64::NEG_INFINITY;@@ -128,18 +128,18 @@ fn gamma_sample(rng: &mut ThreadRng, shape: f64) -> f64 {return 0.0;}if shape < 1.0 {- let u: f64 = rng.gen();+ let u: f64 = rng.random();return gamma_sample(rng, shape + 1.0) * u.powf(1.0 / shape);}let d = shape - 1.0 / 3.0;let c = 1.0 / (9.0 * d).sqrt();loop {- let x: f64 = rng.gen::<f64>() * 2.0 - 1.0;+ let x: f64 = rng.random::<f64>() * 2.0 - 1.0;let v = (1.0 + c * x).powi(3);if v <= 0.0 {continue;}- let u: f64 = rng.gen();+ let u: f64 = rng.random();if u < 1.0 - 0.0331 * x.powi(4) {return d * v;}diff --git a/rust/crates/openjarvis-learning/src/grpo.rs b/rust/crates/openjarvis-learning/src/grpo.rsindex 1a1718b2..675ec837 100644--- a/rust/crates/openjarvis-learning/src/grpo.rs+++ b/rust/crates/openjarvis-learning/src/grpo.rs@@ -51,7 +51,7 @@ impl GRPORouterPolicy {fn softmax_sample(&self) -> String {let weights = self.weights.lock();- let mut rng = thread_rng();+ let mut rng = rand::rng();let logits: Vec<f64> = self.models@@ -66,7 +66,7 @@ impl GRPORouterPolicy {.map(|l| (l - max_logit).exp() / exp_sum).collect();- let u: f64 = rng.gen();+ let u: f64 = rng.random();let mut cumulative = 0.0;for (i, p) in probs.iter().enumerate() {cumulative += p;