Home / Function/ as_bytes_io() — langchain Function Reference

as_bytes_io() — langchain Function Reference

Architecture documentation for the as_bytes_io() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  7d96445f_f767_4973_d287_f97b238652be["as_bytes_io()"]
  3557cb87_7ae6_78b3_0aa2_bbb7f023fdce["Blob"]
  7d96445f_f767_4973_d287_f97b238652be -->|defined in| 3557cb87_7ae6_78b3_0aa2_bbb7f023fdce
  style 7d96445f_f767_4973_d287_f97b238652be fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/documents/base.py lines 195–211

    def as_bytes_io(self) -> Generator[BytesIO | BufferedReader, None, None]:
        """Read data as a byte stream.

        Raises:
            NotImplementedError: If the blob cannot be represented as a byte stream.

        Yields:
            The data as a byte stream.
        """
        if isinstance(self.data, bytes):
            yield BytesIO(self.data)
        elif self.data is None and self.path:
            with Path(self.path).open("rb") as f:
                yield f
        else:
            msg = f"Unable to convert blob {self}"
            raise NotImplementedError(msg)

Subdomains

Frequently Asked Questions

What does as_bytes_io() do?
as_bytes_io() is a function in the langchain codebase, defined in libs/core/langchain_core/documents/base.py.
Where is as_bytes_io() defined?
as_bytes_io() is defined in libs/core/langchain_core/documents/base.py at line 195.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free