base.py — langchain Source File
Architecture documentation for base.py, a python file in the langchain codebase. 12 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0["base.py"] feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> feec1ec4_6917_867b_d228_b134d0ff8099 17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> 17a62cb3_fefd_6320_b757_b53bb4a1c661 e929cf21_6ab8_6ff3_3765_0d35a099a053["langchain_core.language_models"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> e929cf21_6ab8_6ff3_3765_0d35a099a053 628cbc5d_711f_ac0c_2f53_db992d48d7da["langchain_core.output_parsers"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> 628cbc5d_711f_ac0c_2f53_db992d48d7da 5506dcc5_1269_cd23_c6f5_90e719f623e2["langchain_core.output_parsers.json"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> 5506dcc5_1269_cd23_c6f5_90e719f623e2 435e49bf_bb2e_2016_ead7_0afb9d57ad71["langchain_core.prompts"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> 435e49bf_bb2e_2016_ead7_0afb9d57ad71 31eab4ab_7281_1e6c_b17d_12e6ad9de07a["langchain_core.runnables"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> 31eab4ab_7281_1e6c_b17d_12e6ad9de07a dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> dd5e7909_a646_84f1_497b_cae69735550e f85fae70_1011_eaec_151c_4083140ae9e5["typing_extensions"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> f85fae70_1011_eaec_151c_4083140ae9e5 9a0fc770_8c3f_14bc_3c7d_37852927778e["langchain_classic.chains.base"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> 9a0fc770_8c3f_14bc_3c7d_37852927778e 4da4fe6b_2d43_97a0_69ed_0a589e35c5b9["langchain_classic.chains.elasticsearch_database.prompts"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> 4da4fe6b_2d43_97a0_69ed_0a589e35c5b9 87d94c13_c168_56cb_dc76_2e9ec03fb140["elasticsearch"] 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 --> 87d94c13_c168_56cb_dc76_2e9ec03fb140 style 3d1839a5_5c4a_dbb9_a710_2b72a8ac5df0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Chain for interacting with Elasticsearch Database."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from langchain_core.callbacks import CallbackManagerForChainRun
from langchain_core.language_models import BaseLanguageModel
from langchain_core.output_parsers import BaseOutputParser, StrOutputParser
from langchain_core.output_parsers.json import SimpleJsonOutputParser
from langchain_core.prompts import BasePromptTemplate
from langchain_core.runnables import Runnable
from pydantic import ConfigDict, model_validator
from typing_extensions import Self
from langchain_classic.chains.base import Chain
from langchain_classic.chains.elasticsearch_database.prompts import (
ANSWER_PROMPT,
DSL_PROMPT,
)
if TYPE_CHECKING:
from elasticsearch import Elasticsearch
INTERMEDIATE_STEPS_KEY = "intermediate_steps"
class ElasticsearchDatabaseChain(Chain):
"""Chain for interacting with Elasticsearch Database.
Example:
```python
from langchain_classic.chains import ElasticsearchDatabaseChain
from langchain_openai import OpenAI
from elasticsearch import Elasticsearch
database = Elasticsearch("http://localhost:9200")
db_chain = ElasticsearchDatabaseChain.from_llm(OpenAI(), database)
```
"""
query_chain: Runnable
"""Chain for creating the ES query."""
answer_chain: Runnable
"""Chain for answering the user question."""
database: Any = None
"""Elasticsearch database to connect to of type elasticsearch.Elasticsearch."""
top_k: int = 10
"""Number of results to return from the query"""
ignore_indices: list[str] | None = None
include_indices: list[str] | None = None
input_key: str = "question"
output_key: str = "result"
sample_documents_in_index_info: int = 3
return_intermediate_steps: bool = False
"""Whether or not to return the intermediate steps along with the final answer."""
model_config = ConfigDict(
arbitrary_types_allowed=True,
extra="forbid",
// ... (149 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- elasticsearch
- langchain_classic.chains.base
- langchain_classic.chains.elasticsearch_database.prompts
- langchain_core.callbacks
- langchain_core.language_models
- langchain_core.output_parsers
- langchain_core.output_parsers.json
- langchain_core.prompts
- langchain_core.runnables
- 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 AgentOrchestration domain, ClassicChains subdomain.
What functions are defined in base.py?
base.py defines 1 function(s): elasticsearch.
What does base.py depend on?
base.py imports 12 module(s): elasticsearch, langchain_classic.chains.base, langchain_classic.chains.elasticsearch_database.prompts, langchain_core.callbacks, langchain_core.language_models, langchain_core.output_parsers, langchain_core.output_parsers.json, langchain_core.prompts, and 4 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/chains/elasticsearch_database/base.py (domain: AgentOrchestration, subdomain: ClassicChains, directory: libs/langchain/langchain_classic/chains/elasticsearch_database).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free