Skip to content

Commit 426037e

Browse files
authored
Merge pull request #1114 from dcSpark/nico/fix_tests_rust
Nico/fix tests rust
2 parents f8c0466 + ad7d8d9 commit 426037e

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,18 +2011,26 @@ impl Node {
20112011
}
20122012

20132013
// Get the internal_comms preference from the database
2014-
match db.get_preference::<ShinkaiInternalComms>("internal_comms") {
2015-
Ok(Some(internal_comms)) => {
2016-
let _ = res.send(Ok(internal_comms.internal_has_sync_default_tools)).await;
2017-
}
2018-
Ok(None) => {
2019-
let _ = res.send(Ok(false)).await;
2020-
}
2014+
let internal_comms_synced = match db.get_preference::<ShinkaiInternalComms>("internal_comms") {
2015+
Ok(Some(internal_comms)) => internal_comms.internal_has_sync_default_tools,
2016+
Ok(None) => false,
20212017
Err(e) => {
20222018
eprintln!("Error getting internal_comms preference: {}", e);
2023-
let _ = res.send(Ok(false)).await;
2019+
false
20242020
}
2025-
}
2021+
};
2022+
2023+
// Check if Rust tools are installed
2024+
let rust_tools_installed = match db.has_rust_tools() {
2025+
Ok(installed) => installed,
2026+
Err(e) => {
2027+
eprintln!("Error checking Rust tools: {}", e);
2028+
false
2029+
}
2030+
};
2031+
2032+
// Both conditions must be true
2033+
let _ = res.send(Ok(internal_comms_synced && rust_tools_installed)).await;
20262034
Ok(())
20272035
}
20282036

shinkai-bin/shinkai-node/src/tools/tool_execution/execution_custom.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ pub async fn try_to_execute_rust_tool(
3737
) -> Result<Value, ToolError> {
3838
println!("[executing_rust_tool] {}", tool_router_key);
3939

40+
// Note(Important): if you update the # of tools, you need to update the # of tools in fn has_rust_tools(&self) ->
41+
// Result<bool, SqliteManagerError> { ... } in shinkai_sqlite/src/shinkai_tool_manager.rs
42+
4043
let result = match tool_router_key {
4144
// TODO Keep in sync with definitions_custom.rs
4245
s if s == "local:::__official_shinkai:::shinkai_llm_map_reduce_processor" => {

shinkai-bin/shinkai-node/tests/it/tool_config_override_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn test_tool_execution_with_config_override() {
4444
std::env::set_var("WELCOME_MESSAGE", "false");
4545
let api_key_bearer = std::env::var("API_V2_KEY").unwrap_or_else(|_| "my_api_v2_key".to_string());
4646
std::env::set_var("API_V2_KEY", api_key_bearer.clone());
47-
std::env::set_var("NODE_API_PORT", "9550");
47+
std::env::set_var("NODE_API_PORT", "9570");
4848
std::env::set_var("SKIP_IMPORT_FROM_DIRECTORY", "true");
4949
std::env::set_var("IS_TESTING", "1");
5050
let node1_db_path = format!("db_tests/{}", hash_signature_public_key(&unsafe_deterministic_signature_keypair(0).1));
@@ -147,10 +147,10 @@ fn test_tool_execution_with_config_override() {
147147
.await;
148148

149149
// Create node1 and node2
150-
assert!(port_is_available(9550), "Port 9550 is not available");
150+
assert!(port_is_available(9570), "Port 9570 is not available");
151151
assert!(port_is_available(9560), "Port 9560 is not available");
152152
// Setup API Server task
153-
let api_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 9550);
153+
let api_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 9570);
154154
let api_https_listen_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 9560);
155155

156156
let node1_commands_sender_clone = node1_commands_sender.clone();

shinkai-libs/shinkai-sqlite/src/shinkai_tool_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ impl SqliteManager {
704704
SqliteManagerError::DatabaseError(e)
705705
})?;
706706

707-
Ok(count >= 4)
707+
Ok(count >= 7)
708708
}
709709

710710
// Update the FTS table when inserting or updating a tool

0 commit comments

Comments
 (0)