Home / Function/ from_params() — langchain Function Reference

from_params() — langchain Function Reference

Architecture documentation for the from_params() function in mapreduce.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d4b15165_0193_5a67_e7ae_50a24fe2f0aa["from_params()"]
  5201e8ad_1740_ce23_1ab6_cafdbc91f78c["MapReduceChain"]
  d4b15165_0193_5a67_e7ae_50a24fe2f0aa -->|defined in| 5201e8ad_1740_ce23_1ab6_cafdbc91f78c
  style d4b15165_0193_5a67_e7ae_50a24fe2f0aa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/mapreduce.py lines 50–81

    def from_params(
        cls,
        llm: BaseLanguageModel,
        prompt: BasePromptTemplate,
        text_splitter: TextSplitter,
        callbacks: Callbacks = None,
        combine_chain_kwargs: Mapping[str, Any] | None = None,
        reduce_chain_kwargs: Mapping[str, Any] | None = None,
        **kwargs: Any,
    ) -> MapReduceChain:
        """Construct a map-reduce chain that uses the chain for map and reduce."""
        llm_chain = LLMChain(llm=llm, prompt=prompt, callbacks=callbacks)
        stuff_chain = StuffDocumentsChain(
            llm_chain=llm_chain,
            callbacks=callbacks,
            **(reduce_chain_kwargs or {}),
        )
        reduce_documents_chain = ReduceDocumentsChain(
            combine_documents_chain=stuff_chain,
        )
        combine_documents_chain = MapReduceDocumentsChain(
            llm_chain=llm_chain,
            reduce_documents_chain=reduce_documents_chain,
            callbacks=callbacks,
            **(combine_chain_kwargs or {}),
        )
        return cls(
            combine_documents_chain=combine_documents_chain,
            text_splitter=text_splitter,
            callbacks=callbacks,
            **kwargs,
        )

Subdomains

Frequently Asked Questions

What does from_params() do?
from_params() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/mapreduce.py.
Where is from_params() defined?
from_params() is defined in libs/langchain/langchain_classic/chains/mapreduce.py at line 50.

Analyze Your Own Codebase

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

Try Supermodel Free