LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coredocumentsbaseDocument
    Class●Since v0.1

    Document

    Class for storing a piece of text and associated metadata.

    Note

    Document is for retrieval workflows, not chat I/O. For sending text to an LLM in a conversation, use message types from langchain.messages.

    Copy
    Document(
        self,
        page_content: str,
        **kwargs: Any = {},
    )

    Bases

    BaseMedia

    Example:

    from langchain_core.documents import Document
    
    document = Document(
        page_content="Hello, world!", metadata={"source": "https://example.com"}
    )

    Used in Docs

    • Build a RAG agent with LangChain
    • Build a semantic search engine with LangChain
    • (MODULE_NAME) integration
    • AI21SemanticTextSplitter integration
    • Airbyte cdk (Deprecated) integration
    (94 more not shown)

    Constructors

    constructor
    __init__
    NameType
    page_contentstr

    Attributes

    attribute
    page_content: str

    String text.

    attribute
    type: Literal['Document']

    Methods

    method
    is_lc_serializable

    Return True as this class is serializable.

    method
    get_lc_namespace

    Get the namespace of the LangChain object.

    Inherited fromBaseMedia

    Attributes

    Aid: str
    —

    The unique identifier of the node.

    Ametadata: dict[str, Any] | None
    —

    Optional metadata associated with the retriever.

    Inherited fromSerializable

    Attributes

    Alc_secrets: dict[str, str]
    —

    A map of constructor argument names to secret ids.

    Alc_attributes: dict
    —

    List of attribute names that should be included in the serialized kwargs.

    Amodel_config

    Methods

    Mlc_id
    —

    Return a unique identifier for this class for serialization purposes.

    Mto_json
    —

    Convert the graph to a JSON-serializable format.

    Mto_json_not_implemented
    —

    Serialize a "not implemented" object.

    View source on GitHub