From 3531cc300c5089429414f7dd541ce8c27ea3bb98 Mon Sep 17 00:00:00 2001 From: Nico Arqueros Date: Thu, 31 Oct 2024 16:50:25 -0500 Subject: [PATCH] fix --- .../tests/it/db_llm_providers_tests.rs | 15 +-------- .../shinkai-db/src/db/db_llm_providers.rs | 32 ------------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/shinkai-bin/shinkai-node/tests/it/db_llm_providers_tests.rs b/shinkai-bin/shinkai-node/tests/it/db_llm_providers_tests.rs index f68d0c998..6cdd40cfb 100644 --- a/shinkai-bin/shinkai-node/tests/it/db_llm_providers_tests.rs +++ b/shinkai-bin/shinkai-node/tests/it/db_llm_providers_tests.rs @@ -163,11 +163,6 @@ mod tests { let profiles = db.get_llm_provider_profiles_with_access(&test_agent.id, &profile); assert!(profiles.is_ok(), "Failed to get agent profiles"); assert_eq!(vec!["profilename"], profiles.unwrap()); - - // Get agent toolkits accessible - let toolkits = db.get_llm_provider_toolkits_accessible(&test_agent.id, &profile); - assert!(toolkits.is_ok(), "Failed to get agent toolkits"); - assert_eq!(vec!["toolkit1", "toolkit2"], toolkits.unwrap()); } #[test] @@ -200,14 +195,6 @@ mod tests { let profiles = db .get_llm_provider_profiles_with_access(&test_agent.id, &profile) .unwrap(); - assert_eq!(vec!["profilename", "sender2"], profiles); - - // Remove a toolkit from agent access - let result = db.remove_toolkit_from_llm_provider_access(&test_agent.id, "toolkit1", &profile); - assert!(result.is_ok(), "Failed to remove toolkit from agent access"); - let toolkits = db - .get_llm_provider_toolkits_accessible(&test_agent.id, &profile) - .unwrap(); - assert_eq!(vec!["toolkit2"], toolkits); + assert_eq!(vec!["profilename"], profiles); } } diff --git a/shinkai-libs/shinkai-db/src/db/db_llm_providers.rs b/shinkai-libs/shinkai-db/src/db/db_llm_providers.rs index b0c26487a..8629035d3 100644 --- a/shinkai-libs/shinkai-db/src/db/db_llm_providers.rs +++ b/shinkai-libs/shinkai-db/src/db/db_llm_providers.rs @@ -227,38 +227,6 @@ impl ShinkaiDB { Ok(profiles_with_access) } - pub fn get_llm_provider_toolkits_accessible( - &self, - llm_provider_id: &str, - profile: &ShinkaiName, - ) -> Result, ShinkaiDBError> { - let cf_node_and_users = self.cf_handle(Topic::NodeAndUsers.as_str())?; - let llm_provider_id_for_db = Self::db_llm_provider_id(llm_provider_id, profile)?; - let llm_provider_id_for_db_hash = Self::llm_provider_id_to_hash(&llm_provider_id_for_db); - let prefix = format!("agent_{}_toolkit_", llm_provider_id_for_db_hash); - let mut toolkits_accessible = Vec::new(); - - let iter = self.db.prefix_iterator_cf(cf_node_and_users, prefix.as_bytes()); - for item in iter { - match item { - Ok((key, _)) => { - // Extract toolkit name from the key - let key_str = String::from_utf8(key.to_vec()) - .map_err(|_| ShinkaiDBError::DataConversionError("UTF-8 conversion error".to_string()))?; - // Ensure the key follows the prefix convention before extracting the toolkit name - if key_str.starts_with(&prefix) { - if let Some(toolkit_name) = key_str.split('_').last() { - toolkits_accessible.push(toolkit_name.to_string()); - } - } - } - Err(e) => return Err(ShinkaiDBError::RocksDBError(e)), - } - } - - Ok(toolkits_accessible) - } - pub fn remove_profile_from_llm_provider_access( &self, llm_provider_id: &str,