agentscope.service.file.text module

Operators for txt file and directory.

agentscope.service.file.text.read_text_file(file_path: str) ServiceResponse[source]

Read the content of the text file.

Parameters:

file_path (str) – The path to the text file to be read.

Returns:

A tuple (bool, str) where the boolean indicates success, and the str contains the file content or an error message if any, including the error type.

Return type:

ServiceResponse

agentscope.service.file.text.write_text_file(file_path: str, content: str, overwrite: bool = False) ServiceResponse[source]

Write content to a text file.

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

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

  • overwrite (bool, defaults to False) – Whether to overwrite the file if it already exists.

Returns:

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

Return type:

ServiceResponse