Skip to content

Commit

Permalink
cp
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Jan 26, 2024
1 parent fa3a635 commit 96d052d
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub struct JobMessage {
pub job_id: String,
pub content: String,
pub files_inbox: String,
pub parent: Option<String>,
}

impl JobMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ impl ShinkaiMessageBuilder {
job_id: String,
content: String,
files_inbox: String,
parent_hash: String,
my_encryption_secret_key: EncryptionStaticKey,
my_signature_secret_key: SigningKey,
receiver_public_key: EncryptionPublicKey,
Expand All @@ -507,6 +508,7 @@ impl ShinkaiMessageBuilder {
job_id,
content,
files_inbox,
parent: Some(parent_hash),
};
let body = serde_json::to_string(&job_message).map_err(|_| "Failed to serialize job message to JSON")?;

Expand Down Expand Up @@ -541,6 +543,7 @@ impl ShinkaiMessageBuilder {
job_id,
content,
files_inbox,
parent: None,
};
let body = serde_json::to_string(&job_message).map_err(|_| "Failed to serialize job message to JSON")?;

Expand Down
2 changes: 1 addition & 1 deletion src/agent/providers/shinkai_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl LLMProvider for ShinkaiBackend {
ShinkaiLogLevel::Debug,
format!("Call API Response Text: {:?}", response_text).as_str(),
);
// eprintln!("Call API Response Text: {:?}", response_text);
eprintln!("Call API Response Text: {:?}", response_text);

let data_resp: Result<JsonValue, _> = serde_json::from_str(&response_text);

Expand Down
9 changes: 9 additions & 0 deletions src/agent/queue/job_queue_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ mod tests {
job_id: "job_id::123::false".to_string(),
content: "my content".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand All @@ -320,6 +321,7 @@ mod tests {
job_id: "job_id::123::false".to_string(),
content: "my content".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand All @@ -328,6 +330,7 @@ mod tests {
job_id: "job_id::123::false".to_string(),
content: "my content 2".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand Down Expand Up @@ -421,6 +424,7 @@ mod tests {
job_id: "job_id::a1::false".to_string(),
content: "content a1".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand All @@ -429,6 +433,7 @@ mod tests {
job_id: "job_id::a2::false".to_string(),
content: "content a2".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand All @@ -437,6 +442,7 @@ mod tests {
job_id: "job_id::a3::false".to_string(),
content: "content a3".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand All @@ -446,6 +452,7 @@ mod tests {
job_id: "job_id::b1::false".to_string(),
content: "content b1".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand All @@ -455,6 +462,7 @@ mod tests {
job_id: "job_id::c1::false".to_string(),
content: "content c1".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand All @@ -464,6 +472,7 @@ mod tests {
job_id: "job_id::c2::false".to_string(),
content: "content c2".to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand Down
1 change: 1 addition & 0 deletions src/cron_tasks/cron_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ impl CronManager {
job_id: job_id.clone(),
content: "".to_string(),
files_inbox: inbox_name_result.unwrap(),
parent: None,
};

job_manager
Expand Down
2 changes: 2 additions & 0 deletions tests/it/agent_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ fn node_agent_registration() {
&job_id.clone().to_string(),
&message,
"",
"",
)
.await;
}
Expand Down Expand Up @@ -318,6 +319,7 @@ fn node_agent_registration() {
&job_id.clone().to_string(),
&message,
"",
"",
)
.await;

Expand Down
2 changes: 2 additions & 0 deletions tests/it/encrypted_files_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ fn sandwich_messages_with_files_test() {
&job_id.clone().to_string(),
&job_message_content,
&hash_of_aes_encryption_key_hex(symmetrical_sk),
"",
)
.await;

Expand Down Expand Up @@ -405,6 +406,7 @@ fn sandwich_messages_with_files_test() {
&job_id.clone().to_string(),
&new_job_message_content,
"",
"",
)
.await;

Expand Down
1 change: 1 addition & 0 deletions tests/it/job_image_analysis_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ fn job_image_analysis() {
&job_id.clone().to_string(),
&job_message_content,
&hash_of_aes_encryption_key_hex(symmetrical_sk),
"",
)
.await;

Expand Down
2 changes: 2 additions & 0 deletions tests/it/job_manager_concurrency_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ async fn test_process_job_queue_concurrency() {
job_id: format!("job_id::{}::false", i).to_string(),
content: format!("my content {}", i).to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand Down Expand Up @@ -243,6 +244,7 @@ async fn test_sequnetial_process_for_same_job_id() {
job_id: "job_id::123::false".to_string(),
content: format!("my content {}", i).to_string(),
files_inbox: "".to_string(),
parent: None,
},
ShinkaiName::new("@@node1.shinkai/main".to_string()).unwrap(),
);
Expand Down
1 change: 1 addition & 0 deletions tests/it/job_multi_page_cron_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ fn job_from_cron_multi_page() {
&job_id.clone().to_string(),
&job_message_content,
&hash_of_aes_encryption_key_hex(symmetrical_sk),
"",
)
.await;

Expand Down
1 change: 1 addition & 0 deletions tests/it/job_one_page_cron_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ fn job_from_cron_one_page() {
&job_id.clone().to_string(),
&job_message_content,
&hash_of_aes_encryption_key_hex(symmetrical_sk),
"",
)
.await;

Expand Down
9 changes: 2 additions & 7 deletions tests/it/planner_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,16 @@ use shinkai_message_primitives::shinkai_utils::shinkai_message_builder::ShinkaiM
use shinkai_message_primitives::shinkai_utils::signatures::{
clone_signature_secret_key, unsafe_deterministic_signature_keypair,
};
use shinkai_message_primitives::shinkai_utils::utils::hash_string;
use shinkai_node::agent::agent;
use shinkai_node::agent::error::AgentError;
use shinkai_node::cron_tasks::web_scrapper::CronTaskRequest;
use shinkai_node::db::db_cron_task::CronTask;
use shinkai_node::network::node::NodeCommand;
use shinkai_node::network::node_api::APIError;
use shinkai_node::network::Node;
use shinkai_node::planner::kai_files::{KaiJobFile, KaiSchemaType};
use shinkai_vector_resources::resource_errors::VRError;
use std::collections::HashMap;
use std::net::{IpAddr, Ipv4Addr};
use std::path::Path;
use std::time::Instant;
use std::{env, fs};
use std::{net::SocketAddr, time::Duration};
use tokio::runtime::Runtime;
use super::utils::test_boilerplate::run_test_one_node_network;

use super::utils;
Expand Down Expand Up @@ -327,6 +320,7 @@ fn planner_integration_test() {
&job_id.clone().to_string(),
&job_message_content,
&hash_of_aes_encryption_key_hex(symmetrical_sk),
"",
)
.await;

Expand Down Expand Up @@ -403,6 +397,7 @@ fn planner_integration_test() {
&job_id.clone().to_string(),
"dummy message",
"",
"",
)
.await;

Expand Down
5 changes: 2 additions & 3 deletions tests/it/utils/node_test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,14 @@ pub async fn api_message_job(
job_id: &str,
content: &str,
files_inbox: &str,
parent: &str,
) {
{
let full_sender = format!("{}/{}", sender, sender_subidentity);
eprintln!("@@ full_sender: {}", full_sender);

let job_message = ShinkaiMessageBuilder::job_message(
job_id.to_string(),
content.to_string(),
files_inbox.to_string(),
parent.to_string(),
subidentity_encryption_sk.clone(),
clone_signature_secret_key(&subidentity_signature_sk),
node_encryption_pk,
Expand Down

0 comments on commit 96d052d

Please sign in to comment.