Package io.agentscope.core.rag.reader
Class ImageReader
java.lang.Object
io.agentscope.core.rag.reader.ImageReader
- All Implemented Interfaces:
Reader
Image reader implementation that reads image files.
This reader supports various image formats and can optionally extract text from images using OCR (if enabled). The reader creates Document objects with image content that can be used in multimodal RAG systems.
Example usage:
ImageReader reader = new ImageReader(false);
ReaderInput input = ReaderInput.fromString("path/to/image.jpg");
List<Document> documents = reader.read(input).block();
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ImageReader with OCR disabled.ImageReader(boolean enableOCR) Creates a new ImageReader with the specified OCR setting. -
Method Summary
Modifier and TypeMethodDescriptionGets the list of file formats supported by this reader.booleanChecks if OCR is enabled.reactor.core.publisher.Mono<List<io.agentscope.core.rag.model.Document>>read(ReaderInput input) Reads a document and returns a list of chunked Document objects.
-
Constructor Details
-
ImageReader
public ImageReader()Creates a new ImageReader with OCR disabled. -
ImageReader
public ImageReader(boolean enableOCR) Creates a new ImageReader with the specified OCR setting.- Parameters:
enableOCR- true to enable OCR text extraction from images
-
-
Method Details
-
read
public reactor.core.publisher.Mono<List<io.agentscope.core.rag.model.Document>> read(ReaderInput input) Description copied from interface:ReaderReads a document and returns a list of chunked Document objects.Errors during reading are propagated through the Mono via
Mono.error(). -
getSupportedFormats
Description copied from interface:ReaderGets the list of file formats supported by this reader.- Specified by:
getSupportedFormatsin interfaceReader- Returns:
- a list of supported file extensions (e.g., "txt", "md", "pdf")
-
isOcrEnabled
public boolean isOcrEnabled()Checks if OCR is enabled.- Returns:
- true if OCR is enabled
-