ractogateway.rag.readers.base

Abstract base class for all file readers.

class ractogateway.rag.readers.base.BaseReader[source]

Bases: ABC

Read content from a file path, raw bytes, or a binary buffer.

Concrete subclasses must implement _read_path() and may override _read_bytes() to support bytes/buffer input. The public read() method handles all type coercion automatically.

abstract property supported_extensions: frozenset[str]

Lower-case extensions (with dot) this reader handles, e.g. {".pdf"}.

read(source)[source]

Load source and return its content as a Document.

Parameters:

source (str | Path | bytes | BinaryIO) –

str or Path

File path read from disk. Both absolute and relative paths are accepted.

bytes

Raw file bytes. Document.source is set to "<bytes>".

binary file-like object

Any object with a .read() -> bytes method — e.g. io.BytesIO, an open binary file handle, a network stream. Document.source is set to "<buffer>".

Return type:

Document