Class ReaderInput

java.lang.Object
io.agentscope.core.rag.reader.ReaderInput

public class ReaderInput extends Object
Input wrapper for document readers.

This class provides a unified interface for different types of input sources (text strings, file paths, URLs, etc.) that can be read by document readers.

  • Method Details

    • fromString

      public static ReaderInput fromString(String text)
      Creates a ReaderInput from a text string.
      Parameters:
      text - the text content
      Returns:
      a ReaderInput instance
    • fromFile

      public static ReaderInput fromFile(String filePath) throws IOException
      Creates a ReaderInput from a file path.
      Parameters:
      filePath - the path to the file
      Returns:
      a ReaderInput instance
      Throws:
      IOException - if the file cannot be read
    • fromFile

      public static ReaderInput fromFile(Path filePath) throws IOException
      Creates a ReaderInput from a file path.
      Parameters:
      filePath - the path to the file
      Returns:
      a ReaderInput instance
      Throws:
      IOException - if the file cannot be read
    • fromFile

      public static ReaderInput fromFile(File file) throws IOException
      Creates a ReaderInput from a File object.
      Parameters:
      file - the file object
      Returns:
      a ReaderInput instance
      Throws:
      IOException - if the file cannot be read
    • fromPath

      public static ReaderInput fromPath(String path)
      Creates a ReaderInput from a File path string.
      Parameters:
      path - the file path string
      Returns:
      a ReaderInput instance
      Throws:
      IllegalArgumentException - if the path is invalid
    • fromPath

      public static ReaderInput fromPath(Path path)
      Creates a ReaderInput from a File path.
      Parameters:
      path - the file path
      Returns:
      a ReaderInput instance
      Throws:
      IllegalArgumentException - if the path is invalid
    • asString

      public String asString()
      Gets the input content as a string.
      Returns:
      the content string
    • getType

      public ReaderInput.InputType getType()
      Gets the input type.
      Returns:
      the input type