java.lang.Object
com.alibaba.cloud.ai.graph.agent.extension.tools.filesystem.ReadFileTool
All Implemented Interfaces:
BiFunction<ReadFileTool.ReadFileRequest,org.springframework.ai.chat.model.ToolContext,String>

public class ReadFileTool extends Object implements BiFunction<ReadFileTool.ReadFileRequest,org.springframework.ai.chat.model.ToolContext,String>
Tool for reading file contents with pagination support.
  • Field Details

  • Constructor Details

    • ReadFileTool

      public ReadFileTool()
  • Method Details

    • apply

      public String apply(ReadFileTool.ReadFileRequest request, org.springframework.ai.chat.model.ToolContext toolContext)
      Specified by:
      apply in interface BiFunction<ReadFileTool.ReadFileRequest,org.springframework.ai.chat.model.ToolContext,String>
    • readFileContent

      public static String readFileContent(Path filePath, Integer offset, Integer limit, boolean checkEmpty)
      Core logic for reading file content with pagination. This method can be reused by other classes like FileSystemTools.
      Parameters:
      filePath - The path to the file to read
      offset - Line offset to start reading from (null means 0)
      limit - Maximum number of lines to read (null means 500)
      checkEmpty - Whether to check for empty content and return warning
      Returns:
      Formatted file content with line numbers, or error message
    • createReadFileToolCallback

      public static org.springframework.ai.tool.ToolCallback createReadFileToolCallback(String description)