Home / Function/ from_path() — langchain Function Reference

from_path() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/langchain_core/documents/base.py lines 214–248

    def from_path(
        cls,
        path: PathLike,
        *,
        encoding: str = "utf-8",
        mime_type: str | None = None,
        guess_type: bool = True,
        metadata: dict | None = None,
    ) -> Blob:
        """Load the blob from a path like object.

        Args:
            path: Path-like object to file to be read
            encoding: Encoding to use if decoding the bytes into a string
            mime_type: If provided, will be set as the MIME type of the data
            guess_type: If `True`, the MIME type will be guessed from the file
                extension, if a MIME type was not provided
            metadata: Metadata to associate with the `Blob`

        Returns:
            `Blob` instance
        """
        if mime_type is None and guess_type:
            mimetype = mimetypes.guess_type(path)[0]
        else:
            mimetype = mime_type
        # We do not load the data immediately, instead we treat the blob as a
        # reference to the underlying data.
        return cls(
            data=None,
            mimetype=mimetype,
            encoding=encoding,
            path=path,
            metadata=metadata if metadata is not None else {},
        )

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free