Home / Class/ QAWithSourcesChain Class — langchain Architecture

QAWithSourcesChain Class — langchain Architecture

Architecture documentation for the QAWithSourcesChain class in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  e4f7f49b_0535_9083_f037_071fa164fd67["QAWithSourcesChain"]
  5aa1201d_23fd_f122_acb5_563cb1cc3cb3["BaseQAWithSourcesChain"]
  e4f7f49b_0535_9083_f037_071fa164fd67 -->|extends| 5aa1201d_23fd_f122_acb5_563cb1cc3cb3
  a7a68606_993d_1969_b78f_6a63c927fa29["base.py"]
  e4f7f49b_0535_9083_f037_071fa164fd67 -->|defined in| a7a68606_993d_1969_b78f_6a63c927fa29
  a6a97112_a25d_65f1_e9dc_d700f08fdfb7["input_keys()"]
  e4f7f49b_0535_9083_f037_071fa164fd67 -->|method| a6a97112_a25d_65f1_e9dc_d700f08fdfb7
  4a10cb6c_c1d3_3564_10c0_9e6d7abecc05["_get_docs()"]
  e4f7f49b_0535_9083_f037_071fa164fd67 -->|method| 4a10cb6c_c1d3_3564_10c0_9e6d7abecc05
  b40dca0d_0cba_df31_2e04_0f7efd72cbf6["_aget_docs()"]
  e4f7f49b_0535_9083_f037_071fa164fd67 -->|method| b40dca0d_0cba_df31_2e04_0f7efd72cbf6
  4a6e2d16_f27d_e1d5_31d7_8ba2fbeefd3e["_chain_type()"]
  e4f7f49b_0535_9083_f037_071fa164fd67 -->|method| 4a6e2d16_f27d_e1d5_31d7_8ba2fbeefd3e

Relationship Graph

Source Code

libs/langchain/langchain_classic/chains/qa_with_sources/base.py lines 227–259

class QAWithSourcesChain(BaseQAWithSourcesChain):
    """Question answering with sources over documents."""

    input_docs_key: str = "docs"

    @property
    def input_keys(self) -> list[str]:
        """Expect input key."""
        return [self.input_docs_key, self.question_key]

    @override
    def _get_docs(
        self,
        inputs: dict[str, Any],
        *,
        run_manager: CallbackManagerForChainRun,
    ) -> list[Document]:
        """Get docs to run questioning over."""
        return inputs.pop(self.input_docs_key)

    @override
    async def _aget_docs(
        self,
        inputs: dict[str, Any],
        *,
        run_manager: AsyncCallbackManagerForChainRun,
    ) -> list[Document]:
        """Get docs to run questioning over."""
        return inputs.pop(self.input_docs_key)

    @property
    def _chain_type(self) -> str:
        return "qa_with_sources_chain"

Frequently Asked Questions

What is the QAWithSourcesChain class?
QAWithSourcesChain is a class in the langchain codebase, defined in libs/langchain/langchain_classic/chains/qa_with_sources/base.py.
Where is QAWithSourcesChain defined?
QAWithSourcesChain is defined in libs/langchain/langchain_classic/chains/qa_with_sources/base.py at line 227.
What does QAWithSourcesChain extend?
QAWithSourcesChain extends BaseQAWithSourcesChain.

Analyze Your Own Codebase

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

Try Supermodel Free