Home / Function/ from_data() — langchain Function Reference

from_data() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/langchain_core/documents/base.py lines 251–278

    def from_data(
        cls,
        data: str | bytes,
        *,
        encoding: str = "utf-8",
        mime_type: str | None = None,
        path: str | None = None,
        metadata: dict | None = None,
    ) -> Blob:
        """Initialize the `Blob` from in-memory data.

        Args:
            data: The in-memory data associated with the `Blob`
            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
            path: If provided, will be set as the source from which the data came
            metadata: Metadata to associate with the `Blob`

        Returns:
            `Blob` instance
        """
        return cls(
            data=data,
            mimetype=mime_type,
            encoding=encoding,
            path=path,
            metadata=metadata if metadata is not None else {},
        )

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free