Skip to content

Commit

Permalink
extend api support
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Jan 9, 2025
1 parent 31844aa commit 5387089
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ impl Node {

let vr_path = ShinkaiPath::from_string(input_payload.path);

let depth = input_payload.depth.unwrap_or(1);

// Use list_directory_contents_with_depth to get directory contents with depth 1
let directory_contents = ShinkaiFileManager::list_directory_contents_with_depth(vr_path, &db, 1);
let directory_contents = ShinkaiFileManager::list_directory_contents_with_depth(vr_path, &db, depth);

if let Err(e) = directory_contents {
let api_error = APIError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ impl ShinkaiTestingFramework {

/// Retrieves simplified path information and optionally prints it based on `should_print`.
pub async fn retrieve_and_print_path_simplified(&self, path: &str, should_print: bool) -> serde_json::Value {
let payload = APIVecFsRetrievePathSimplifiedJson { path: path.to_string() };
let payload = APIVecFsRetrievePathSimplifiedJson {
path: path.to_string(),
depth: Some(1),
};
let msg = generate_message_with_payload(
serde_json::to_string(&payload).unwrap(),
MessageSchemaType::VecFsRetrievePathSimplifiedJson,
Expand Down
5 changes: 4 additions & 1 deletion shinkai-bin/shinkai-node/tests/it/utils/vecfs_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ pub async fn retrieve_file_info(
path: &str,
is_simple: bool,
) -> Value {
let payload = APIVecFsRetrievePathSimplifiedJson { path: path.to_string() };
let payload = APIVecFsRetrievePathSimplifiedJson {
path: path.to_string(),
depth: Some(1),
};

let msg = generate_message_with_payload(
serde_json::to_string(&payload).unwrap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ pub struct APIAddAgentRequest {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, ToSchema)]
pub struct APIVecFsRetrievePathSimplifiedJson {
pub path: String,
pub depth: Option<usize>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, ToSchema)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ impl ShinkaiMessageBuilder {
#[allow(dead_code)]
pub fn vecfs_retrieve_path_simplified(
path: &str,
depth: Option<usize>,
my_encryption_secret_key: EncryptionStaticKey,
my_signature_secret_key: SigningKey,
receiver_public_key: EncryptionPublicKey,
Expand All @@ -388,7 +389,10 @@ impl ShinkaiMessageBuilder {
node_receiver: ShinkaiNameString,
node_receiver_subidentity: ShinkaiNameString,
) -> Result<ShinkaiMessage, &'static str> {
let payload = APIVecFsRetrievePathSimplifiedJson { path: path.to_string() };
let payload = APIVecFsRetrievePathSimplifiedJson {
path: path.to_string(),
depth: depth,
};

Self::create_vecfs_message(
payload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ mod tests {
description: "Fetches emails from an IMAP server".to_string(),
keywords: vec!["email".to_string(), "imap".to_string()],
js_code: "".to_string(),
tools: None,
tools: vec![],
config: vec![
ToolConfig::BasicConfig(BasicConfig {
key_name: "imap_server".to_string(),
Expand Down

0 comments on commit 5387089

Please sign in to comment.