agentscope.service.file.text module

Operators for txt file and directory.

agentscope.service.file.text.read_text_file(file_path: str) ServiceResponse[源代码]

Read the content of the text file.

参数:

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

返回:

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.

返回类型:

ServiceResponse

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

Write content to a text file.

参数:
  • 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.

返回:

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

返回类型:

ServiceResponse