base.py — langchain Source File
Architecture documentation for base.py, a python file in the langchain codebase. 19 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR fdc86f9f_85df_84cf_83a4_a9e587fe40ec["base.py"] 614e7b9f_ed51_0780_749c_ff40b74963fc["inspect"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> 614e7b9f_ed51_0780_749c_ff40b74963fc 67ec3255_645e_8b6e_1eff_1eb3c648ed95["re"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> 67ec3255_645e_8b6e_1eff_1eb3c648ed95 cccbe73e_4644_7211_4d55_e8fb133a8014["abc"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> cccbe73e_4644_7211_4d55_e8fb133a8014 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 b19a8b7e_fbee_95b1_65b8_509a1ed3cad7["langchain_core._api"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> b19a8b7e_fbee_95b1_65b8_509a1ed3cad7 f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> f3bc7443_c889_119d_0744_aacc3620d8d2 c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> c554676d_b731_47b2_a98f_c1c2d537c0aa ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> ba43b74d_3099_7e1c_aac3_cf594720469e e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> e6b4f61e_7b98_6666_3641_26b069517d4a 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> 91721f45_4909_e489_8c1f_084f8bd87145 9b4ec80f_d8de_a6e0_4f16_67ba56685088["langchain_classic.chains"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> 9b4ec80f_d8de_a6e0_4f16_67ba56685088 01158a5b_b299_f45d_92e9_2a7433a1a91a["langchain_classic.chains.base"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> 01158a5b_b299_f45d_92e9_2a7433a1a91a a0d4f6c3_2d96_364c_720a_e778ffd171a0["langchain_classic.chains.combine_documents.base"] fdc86f9f_85df_84cf_83a4_a9e587fe40ec --> a0d4f6c3_2d96_364c_720a_e778ffd171a0 style fdc86f9f_85df_84cf_83a4_a9e587fe40ec fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Question answering with sources over documents."""
from __future__ import annotations
import inspect
import re
from abc import ABC, abstractmethod
from typing import Any
from langchain_core._api import deprecated
from langchain_core.callbacks import (
AsyncCallbackManagerForChainRun,
CallbackManagerForChainRun,
)
from langchain_core.documents import Document
from langchain_core.language_models import BaseLanguageModel
from langchain_core.prompts import BasePromptTemplate
from pydantic import ConfigDict, model_validator
from typing_extensions import override
from langchain_classic.chains import ReduceDocumentsChain
from langchain_classic.chains.base import Chain
from langchain_classic.chains.combine_documents.base import BaseCombineDocumentsChain
from langchain_classic.chains.combine_documents.map_reduce import (
MapReduceDocumentsChain,
)
from langchain_classic.chains.combine_documents.stuff import StuffDocumentsChain
from langchain_classic.chains.llm import LLMChain
from langchain_classic.chains.qa_with_sources.loading import load_qa_with_sources_chain
from langchain_classic.chains.qa_with_sources.map_reduce_prompt import (
COMBINE_PROMPT,
EXAMPLE_PROMPT,
QUESTION_PROMPT,
)
@deprecated(
since="0.2.13",
removal="1.0",
message=(
"This class is deprecated. Refer to this guide on retrieval and question "
"answering with sources: "
"https://python.langchain.com/docs/how_to/qa_sources/"
),
)
class BaseQAWithSourcesChain(Chain, ABC):
"""Question answering chain with sources over documents."""
combine_documents_chain: BaseCombineDocumentsChain
"""Chain to use to combine documents."""
question_key: str = "question"
input_docs_key: str = "docs"
answer_key: str = "answer"
sources_answer_key: str = "sources"
return_source_documents: bool = False
"""Return the source documents."""
@classmethod
def from_llm(
cls,
// ... (200 more lines)
Domain
Subdomains
Dependencies
- abc
- inspect
- langchain_classic.chains
- langchain_classic.chains.base
- langchain_classic.chains.combine_documents.base
- langchain_classic.chains.combine_documents.map_reduce
- langchain_classic.chains.combine_documents.stuff
- langchain_classic.chains.llm
- langchain_classic.chains.qa_with_sources.loading
- langchain_classic.chains.qa_with_sources.map_reduce_prompt
- langchain_core._api
- langchain_core.callbacks
- langchain_core.documents
- langchain_core.language_models
- langchain_core.prompts
- pydantic
- re
- typing
- typing_extensions
Source
Frequently Asked Questions
What does base.py do?
base.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What does base.py depend on?
base.py imports 19 module(s): abc, inspect, langchain_classic.chains, langchain_classic.chains.base, langchain_classic.chains.combine_documents.base, langchain_classic.chains.combine_documents.map_reduce, langchain_classic.chains.combine_documents.stuff, langchain_classic.chains.llm, and 11 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/chains/qa_with_sources/base.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/langchain_classic/chains/qa_with_sources).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free