From fa22251d52b1988e63fe209873095220918fda7e Mon Sep 17 00:00:00 2001 From: Eddie Date: Mon, 23 Dec 2024 19:45:33 -0300 Subject: [PATCH] fix merge --- .../shinkai-node/src/managers/tool_router.rs | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/shinkai-bin/shinkai-node/src/managers/tool_router.rs b/shinkai-bin/shinkai-node/src/managers/tool_router.rs index 2fb5ce447..42a533fb0 100644 --- a/shinkai-bin/shinkai-node/src/managers/tool_router.rs +++ b/shinkai-bin/shinkai-node/src/managers/tool_router.rs @@ -70,44 +70,7 @@ impl ToolRouter { .map_err(|e| ToolError::DatabaseError(e.to_string()))?; } - // Import tools - async fn import_tools_from_directory(db: Arc) -> Result<(), ToolError> { - let url = env::var("SHINKAI_TOOLS_DIRECTORY_URL") - .map_err(|_| ToolError::MissingConfigError("SHINKAI_TOOLS_DIRECTORY_URL not set".to_string()))?; - - let response = reqwest::get(url).await.map_err(|e| ToolError::RequestError(e))?; - - if response.status() != 200 { - return Err(ToolError::ExecutionError(format!( - "Import tools request returned a non OK status: {}", - response.status() - ))); - } - - let tools: Vec = response - .json() - .await - .map_err(|e| ToolError::ParseError(format!("Failed to parse tools directory: {}", e)))?; - - for tool in tools { - let tool_url = tool["file"].as_str().ok_or_else(|| { - ToolError::ParseError("Missing or invalid file URL in tool definition".to_string()) - })?; - - let tool_name = tool["name"].as_str().unwrap_or("unknown"); - - match Node::v2_api_import_tool_internal(db.clone(), fetch_node_environment(), tool_url.to_string()) - .await - { - Ok(_) => println!("Successfully imported tool {}", tool_name), - Err(e) => eprintln!("Failed to import tool {}: {:#?}", tool_name, e), - } - } - - Ok(()) - } - - if let Err(e) = import_tools_from_directory(self.sqlite_manager.clone()).await { + if let Err(e) = Self::import_tools_from_directory(self.sqlite_manager.clone()).await { eprintln!("Error importing tools from directory: {}", e); }