agentscope.service.file.common module

Common operators for file and directory.

agentscope.service.file.common.create_file(file_path: str, content: str = '') ServiceResponse[source]

Create a file and write content to it.

Parameters:
  • file_path (str) – The path where the file will be created.

  • content (str) – Content to write into the file.

Returns:

Where the boolean indicates success, and the str contains an error message if any, including the error type.

Return type:

ServiceResponse

agentscope.service.file.common.delete_file(file_path: str) ServiceResponse[source]

Delete a file specified by the file path.

Parameters:

file_path (str) – The path of the file to be deleted.

Returns:

Where the boolean indicates success, and the str contains an error message if any, including the error type.

Return type:

ServiceResponse

agentscope.service.file.common.move_file(source_path: str, destination_path: str) ServiceResponse[source]

Move a file from a source path to a destination path.

Parameters:
  • source_path (str) – The current path of the file.

  • destination_path (str) – The new path for the file.

Returns:

Where the boolean indicates success, and the str contains an error message if any, including the error type.

Return type:

ServiceResponse

agentscope.service.file.common.create_directory(directory_path: str) ServiceResponse[source]

Create a directory at the specified path.

Parameters:

directory_path (str) – The path where the directory will be created.

Returns:

where the boolean indicates success, and the str contains an error message if any, including the error type.

Return type:

ServiceResponse

agentscope.service.file.common.delete_directory(directory_path: str) ServiceResponse[source]

Delete a directory and all of its contents.

Parameters:

directory_path (str) – The path of the directory to be deleted.

Returns:

Where the boolean indicates success, and the str contains an error message if any, including the error type.

Return type:

ServiceResponse

agentscope.service.file.common.move_directory(source_path: str, destination_path: str) ServiceResponse[source]

Move a directory from a source path to a destination path.

Parameters:
  • source_path (str) – The current path of the directory.

  • destination_path (str) – The new path for the directory.

Returns:

Where the boolean indicates success, and the str contains an error message if any, including the error type.

Return type:

ServiceResponse

agentscope.service.file.common.list_directory_content(directory_path: str) ServiceResponse[source]

List the contents of a directory. i.e. ls -a

Parameters:

directory_path (str) – The path of the directory to show.

Returns:

The results contain a list of direcotry contents, or an error message if any, including the error type.

Return type:

ServiceResponse

agentscope.service.file.common.get_current_directory() ServiceResponse[source]

Get the current working directory path.

Returns:

The current working directory path, or an error message if any, including the error type.

Return type:

ServiceResponse