base.py — langchain Source File
Architecture documentation for base.py, a python file in the langchain codebase. 18 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d3aa4510_51a9_c393_bb4a_23fe112c52cd["base.py"] 614e7b9f_ed51_0780_749c_ff40b74963fc["inspect"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> 614e7b9f_ed51_0780_749c_ff40b74963fc cccbe73e_4644_7211_4d55_e8fb133a8014["abc"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> cccbe73e_4644_7211_4d55_e8fb133a8014 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 b19a8b7e_fbee_95b1_65b8_509a1ed3cad7["langchain_core._api"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> b19a8b7e_fbee_95b1_65b8_509a1ed3cad7 f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> f3bc7443_c889_119d_0744_aacc3620d8d2 c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> c554676d_b731_47b2_a98f_c1c2d537c0aa ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> ba43b74d_3099_7e1c_aac3_cf594720469e e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> e6b4f61e_7b98_6666_3641_26b069517d4a 38bc5323_3713_7377_32f8_091293bea54b["langchain_core.retrievers"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> 38bc5323_3713_7377_32f8_091293bea54b d55af636_303c_0eb6_faee_20d89bd952d5["langchain_core.vectorstores"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> d55af636_303c_0eb6_faee_20d89bd952d5 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> 91721f45_4909_e489_8c1f_084f8bd87145 01158a5b_b299_f45d_92e9_2a7433a1a91a["langchain_classic.chains.base"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> 01158a5b_b299_f45d_92e9_2a7433a1a91a a0d4f6c3_2d96_364c_720a_e778ffd171a0["langchain_classic.chains.combine_documents.base"] d3aa4510_51a9_c393_bb4a_23fe112c52cd --> a0d4f6c3_2d96_364c_720a_e778ffd171a0 style d3aa4510_51a9_c393_bb4a_23fe112c52cd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Chain for question-answering against a vector database."""
from __future__ import annotations
import inspect
from abc import abstractmethod
from typing import Any
from langchain_core._api import deprecated
from langchain_core.callbacks import (
AsyncCallbackManagerForChainRun,
CallbackManagerForChainRun,
Callbacks,
)
from langchain_core.documents import Document
from langchain_core.language_models import BaseLanguageModel
from langchain_core.prompts import PromptTemplate
from langchain_core.retrievers import BaseRetriever
from langchain_core.vectorstores import VectorStore
from pydantic import ConfigDict, Field, model_validator
from typing_extensions import override
from langchain_classic.chains.base import Chain
from langchain_classic.chains.combine_documents.base import BaseCombineDocumentsChain
from langchain_classic.chains.combine_documents.stuff import StuffDocumentsChain
from langchain_classic.chains.llm import LLMChain
from langchain_classic.chains.question_answering import load_qa_chain
from langchain_classic.chains.question_answering.stuff_prompt import PROMPT_SELECTOR
@deprecated(
since="0.2.13",
removal="1.0",
message=(
"This class is deprecated. Use the `create_retrieval_chain` constructor "
"instead. See migration guide here: "
"https://python.langchain.com/docs/versions/migrating_chains/retrieval_qa/"
),
)
class BaseRetrievalQA(Chain):
"""Base class for question-answering chains."""
combine_documents_chain: BaseCombineDocumentsChain
"""Chain to use to combine the documents."""
input_key: str = "query"
output_key: str = "result"
return_source_documents: bool = False
"""Return the source documents or not."""
model_config = ConfigDict(
populate_by_name=True,
arbitrary_types_allowed=True,
extra="forbid",
)
@property
def input_keys(self) -> list[str]:
"""Input keys."""
return [self.input_key]
// ... (309 more lines)
Domain
Subdomains
Dependencies
- abc
- inspect
- langchain_classic.chains.base
- langchain_classic.chains.combine_documents.base
- langchain_classic.chains.combine_documents.stuff
- langchain_classic.chains.llm
- langchain_classic.chains.question_answering
- langchain_classic.chains.question_answering.stuff_prompt
- langchain_core._api
- langchain_core.callbacks
- langchain_core.documents
- langchain_core.language_models
- langchain_core.prompts
- langchain_core.retrievers
- langchain_core.vectorstores
- pydantic
- 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 18 module(s): abc, inspect, langchain_classic.chains.base, langchain_classic.chains.combine_documents.base, langchain_classic.chains.combine_documents.stuff, langchain_classic.chains.llm, langchain_classic.chains.question_answering, langchain_classic.chains.question_answering.stuff_prompt, and 10 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/chains/retrieval_qa/base.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/langchain_classic/chains/retrieval_qa).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free