Document#

class langchain_core.documents.base.Document[source]#

Bases: BaseMedia

Class for storing a piece of text and associated metadata.

Example

from langchain_core.documents import Document

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

Pass page_content in as positional or named arg.

param id: str | None = None#

An optional identifier for the document.

Ideally this should be unique across the document collection and formatted as a UUID, but this will not be enforced.

Added in version 0.2.11.

param metadata: dict [Optional]#

Arbitrary metadata associated with the content.

param page_content: str [Required]#

String text.

param type: Literal['Document'] = 'Document'#

Examples using Document