Home / Function/ from_chain_type() — langchain Function Reference

from_chain_type() — langchain Function Reference

Architecture documentation for the from_chain_type() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f699b18b_e2ec_7138_7958_1411aa99722f["from_chain_type()"]
  5aa1201d_23fd_f122_acb5_563cb1cc3cb3["BaseQAWithSourcesChain"]
  f699b18b_e2ec_7138_7958_1411aa99722f -->|defined in| 5aa1201d_23fd_f122_acb5_563cb1cc3cb3
  style f699b18b_e2ec_7138_7958_1411aa99722f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/qa_with_sources/base.py lines 89–103

    def from_chain_type(
        cls,
        llm: BaseLanguageModel,
        chain_type: str = "stuff",
        chain_type_kwargs: dict | None = None,
        **kwargs: Any,
    ) -> BaseQAWithSourcesChain:
        """Load chain from chain type."""
        _chain_kwargs = chain_type_kwargs or {}
        combine_documents_chain = load_qa_with_sources_chain(
            llm,
            chain_type=chain_type,
            **_chain_kwargs,
        )
        return cls(combine_documents_chain=combine_documents_chain, **kwargs)

Subdomains

Frequently Asked Questions

What does from_chain_type() do?
from_chain_type() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/qa_with_sources/base.py.
Where is from_chain_type() defined?
from_chain_type() is defined in libs/langchain/langchain_classic/chains/qa_with_sources/base.py at line 89.

Analyze Your Own Codebase

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

Try Supermodel Free