_load_map_reduce_documents_chain() — langchain Function Reference
Architecture documentation for the _load_map_reduce_documents_chain() function in loading.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 30094e71_1495_af51_d93f_0de6d110da9d["_load_map_reduce_documents_chain()"] 61dd5a0b_3bf7_b973_6dac_edfd465b21fb["loading.py"] 30094e71_1495_af51_d93f_0de6d110da9d -->|defined in| 61dd5a0b_3bf7_b973_6dac_edfd465b21fb 7c915b91_f326_1908_9969_d0cb1f4f7e34["load_chain_from_config()"] 30094e71_1495_af51_d93f_0de6d110da9d -->|calls| 7c915b91_f326_1908_9969_d0cb1f4f7e34 ab90e794_4e78_646b_dee9_e87a00250d94["load_chain()"] 30094e71_1495_af51_d93f_0de6d110da9d -->|calls| ab90e794_4e78_646b_dee9_e87a00250d94 f01823ee_2304_5ece_d221_f5016c463bd7["_load_reduce_documents_chain()"] 30094e71_1495_af51_d93f_0de6d110da9d -->|calls| f01823ee_2304_5ece_d221_f5016c463bd7 style 30094e71_1495_af51_d93f_0de6d110da9d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/loading.py lines 148–182
def _load_map_reduce_documents_chain(
config: dict,
**kwargs: Any,
) -> MapReduceDocumentsChain:
if "llm_chain" in config:
llm_chain_config = config.pop("llm_chain")
llm_chain = load_chain_from_config(llm_chain_config, **kwargs)
elif "llm_chain_path" in config:
llm_chain = load_chain(config.pop("llm_chain_path"), **kwargs)
else:
msg = "One of `llm_chain` or `llm_chain_path` must be present."
raise ValueError(msg)
if not isinstance(llm_chain, LLMChain):
msg = f"Expected LLMChain, got {llm_chain}"
raise ValueError(msg) # noqa: TRY004
if "reduce_documents_chain" in config:
reduce_documents_chain = load_chain_from_config(
config.pop("reduce_documents_chain"),
**kwargs,
)
elif "reduce_documents_chain_path" in config:
reduce_documents_chain = load_chain(
config.pop("reduce_documents_chain_path"),
**kwargs,
)
else:
reduce_documents_chain = _load_reduce_documents_chain(config, **kwargs)
return MapReduceDocumentsChain(
llm_chain=llm_chain,
reduce_documents_chain=reduce_documents_chain,
**config,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does _load_map_reduce_documents_chain() do?
_load_map_reduce_documents_chain() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/loading.py.
Where is _load_map_reduce_documents_chain() defined?
_load_map_reduce_documents_chain() is defined in libs/langchain/langchain_classic/chains/loading.py at line 148.
What does _load_map_reduce_documents_chain() call?
_load_map_reduce_documents_chain() calls 3 function(s): _load_reduce_documents_chain, load_chain, load_chain_from_config.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free