LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    MCP Adapters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-classicchainscombine_documentsbaseAnalyzeDocumentChain
    Class●Since v1.0Deprecated

    AnalyzeDocumentChain

    Copy
    AnalyzeDocumentChain
    (
    )

    Bases

    Chain

    Attributes

    attribute
    input_key: str
    attribute
    text_splitter: TextSplitter
    attribute
    combine_docs_chain: BaseCombineDocumentsChain
    attribute
    input_keys: list[str]
    attribute
    output_keys: list[str]

    Methods

    method
    get_input_schema
    method
    get_output_schema

    Inherited fromChain

    Attributes

    Amemory: BaseMemory | None
    —

    Optional memory object.

    Acallbacks: CallbacksAverbose: boolAtags: list[str] | NoneAmetadata: dict[str, Any] | NoneAcallback_manager: BaseCallbackManager | None
    —

    [DEPRECATED] Use callbacks instead.

    Amodel_config

    Methods

    MinvokeMainvokeMraise_callback_manager_deprecation
    —

    Raise deprecation warning if callback_manager is used.

    Mset_verbose
    —

    Set the chain verbosity.

    Macall
    —

    Inherited fromRunnableSerializable(langchain_core)

    Attributes

    AnameAmodel_config

    Methods

    Mto_jsonMconfigurable_fields

    Inherited fromSerializable(langchain_core)

    Attributes

    Alc_secretsAlc_attributesAmodel_config

    Methods

    Mis_lc_serializable

    Inherited fromRunnable(langchain_core)

    Attributes

    AnameAInputTypeAOutputTypeAinput_schemaA
    View source on GitHub

    Chain that splits documents, then analyzes it in pieces.

    This chain is parameterized by a TextSplitter and a CombineDocumentsChain. This chain takes a single document as input, and then splits it up into chunks and then passes those chucks to the CombineDocumentsChain.

    This class is deprecated. See below for alternative implementations which supports async and streaming modes of operation.

    If the underlying combine documents chain takes one input_documents argument (e.g., chains generated by load_summarize_chain):

    split_text = lambda x: text_splitter.create_documents([x])
    
    summarize_document_chain = split_text | chain

    If the underlying chain takes additional arguments (e.g., load_qa_chain, which takes an additional question argument), we can use the following:

    from operator import itemgetter
    from langchain_core.runnables import RunnableLambda, RunnableParallel
    
    split_text = RunnableLambda(lambda x: text_splitter.create_documents([x]))
    summarize_document_chain = RunnableParallel(
        question=itemgetter("question"),
        input_documents=itemgetter("input_document") | split_text,
    ) | chain.pick("output_text")

    To additionally return the input parameters, as AnalyzeDocumentChain does, we can wrap this construction with RunnablePassthrough:

    from operator import itemgetter
    from langchain_core.runnables import (
        RunnableLambda,
        RunnableParallel,
        RunnablePassthrough,
    )
    
    split_text = RunnableLambda(lambda x: text_splitter.create_documents([x]))
    summarize_document_chain = RunnablePassthrough.assign(
        output_text=RunnableParallel(
            question=itemgetter("question"),
            input_documents=itemgetter("input_document") | split_text,
        )
        | chain.pick("output_text")
    )

    Asynchronously execute the chain.

    Mprep_outputs
    —

    Validate and prepare chain outputs, and save info about this run to memory.

    Maprep_outputs
    —

    Validate and prepare chain outputs, and save info about this run to memory.

    Mprep_inputs
    —

    Prepare chain inputs, including adding inputs from memory.

    Maprep_inputs
    —

    Prepare chain inputs, including adding inputs from memory.

    Mrun
    —

    Convenience method for executing chain.

    Marun
    —

    Convenience method for executing chain.

    Mdict
    —

    Return dictionary representation of agent.

    Msave
    —

    Save the agent.

    Mapply
    —

    Utilize the LLM generate method for speed gains.

    M
    configurable_alternatives
    M
    get_lc_namespace
    Mlc_id
    Mto_json
    Mto_json_not_implemented
    output_schema
    Aconfig_specs

    Methods

    Mget_nameMget_input_jsonschemaMget_output_jsonschemaMconfig_schemaMget_config_jsonschemaMget_graphMget_promptsMpipeMpickMassignMinvokeMainvokeMbatchMbatch_as_completedMabatchMabatch_as_completedMstreamMastreamMastream_logMastream_eventsMtransformMatransformMbindMwith_configMwith_listenersMwith_alistenersMwith_typesMwith_retryMmapMwith_fallbacksMas_tool

    Expect input key.

    Return output key.