Home / Function/ source() — langchain Function Reference

source() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/langchain_core/documents/base.py lines 137–147

    def source(self) -> str | None:
        """The source location of the blob as string if known otherwise none.

        If a path is associated with the `Blob`, it will default to the path location.

        Unless explicitly set via a metadata field called `'source'`, in which
        case that value will be used instead.
        """
        if self.metadata and "source" in self.metadata:
            return cast("str | None", self.metadata["source"])
        return str(self.path) if self.path else None

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free