base.py — langchain Source File
Architecture documentation for base.py, a python file in the langchain codebase. 17 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 356f1882_f802_ae8d_971b_9adf83ef86ea["base.py"] cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 b19a8b7e_fbee_95b1_65b8_509a1ed3cad7["langchain_core._api"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> b19a8b7e_fbee_95b1_65b8_509a1ed3cad7 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b["langchain_core.agents"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> 80d582c5_7cc3_ac96_2742_3dbe1cbd4e2b f3bc7443_c889_119d_0744_aacc3620d8d2["langchain_core.callbacks"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> f3bc7443_c889_119d_0744_aacc3620d8d2 ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> ba43b74d_3099_7e1c_aac3_cf594720469e e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> e6b4f61e_7b98_6666_3641_26b069517d4a e45722a2_0136_a972_1f58_7b5987500404["langchain_core.prompts.chat"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> e45722a2_0136_a972_1f58_7b5987500404 43d88577_548b_2248_b01b_7987bae85dcc["langchain_core.tools"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> 43d88577_548b_2248_b01b_7987bae85dcc 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> 91721f45_4909_e489_8c1f_084f8bd87145 0569002b_723c_e521_6645_d02d74dd6913["langchain_classic._api.deprecation"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> 0569002b_723c_e521_6645_d02d74dd6913 e160f068_75de_4342_6673_9969b919de85["langchain_classic.agents.agent"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> e160f068_75de_4342_6673_9969b919de85 877cb291_dfed_f8ac_1313_a40a0e86b931["langchain_classic.agents.chat.output_parser"] 356f1882_f802_ae8d_971b_9adf83ef86ea --> 877cb291_dfed_f8ac_1313_a40a0e86b931 style 356f1882_f802_ae8d_971b_9adf83ef86ea fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from collections.abc import Sequence
from typing import Any
from langchain_core._api import deprecated
from langchain_core.agents import AgentAction
from langchain_core.callbacks import BaseCallbackManager
from langchain_core.language_models import BaseLanguageModel
from langchain_core.prompts import BasePromptTemplate
from langchain_core.prompts.chat import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
SystemMessagePromptTemplate,
)
from langchain_core.tools import BaseTool
from pydantic import Field
from typing_extensions import override
from langchain_classic._api.deprecation import AGENT_DEPRECATION_WARNING
from langchain_classic.agents.agent import Agent, AgentOutputParser
from langchain_classic.agents.chat.output_parser import ChatOutputParser
from langchain_classic.agents.chat.prompt import (
FORMAT_INSTRUCTIONS,
HUMAN_MESSAGE,
SYSTEM_MESSAGE_PREFIX,
SYSTEM_MESSAGE_SUFFIX,
)
from langchain_classic.agents.utils import validate_tools_single_input
from langchain_classic.chains.llm import LLMChain
@deprecated(
"0.1.0",
message=AGENT_DEPRECATION_WARNING,
removal="1.0",
)
class ChatAgent(Agent):
"""Chat Agent."""
output_parser: AgentOutputParser = Field(default_factory=ChatOutputParser)
"""Output parser for the agent."""
@property
def observation_prefix(self) -> str:
"""Prefix to append the observation with."""
return "Observation: "
@property
def llm_prefix(self) -> str:
"""Prefix to append the llm call with."""
return "Thought:"
def _construct_scratchpad(
self,
intermediate_steps: list[tuple[AgentAction, str]],
) -> str:
agent_scratchpad = super()._construct_scratchpad(intermediate_steps)
if not isinstance(agent_scratchpad, str):
msg = "agent_scratchpad should be of type string."
raise ValueError(msg) # noqa: TRY004
if agent_scratchpad:
// ... (119 more lines)
Domain
Subdomains
Classes
Dependencies
- collections.abc
- langchain_classic._api.deprecation
- langchain_classic.agents.agent
- langchain_classic.agents.chat.output_parser
- langchain_classic.agents.chat.prompt
- langchain_classic.agents.utils
- langchain_classic.chains.llm
- langchain_core._api
- langchain_core.agents
- langchain_core.callbacks
- langchain_core.language_models
- langchain_core.prompts
- langchain_core.prompts.chat
- langchain_core.tools
- 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, ActionLogic subdomain.
What does base.py depend on?
base.py imports 17 module(s): collections.abc, langchain_classic._api.deprecation, langchain_classic.agents.agent, langchain_classic.agents.chat.output_parser, langchain_classic.agents.chat.prompt, langchain_classic.agents.utils, langchain_classic.chains.llm, langchain_core._api, and 9 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/agents/chat/base.py (domain: AgentOrchestration, subdomain: ActionLogic, directory: libs/langchain/langchain_classic/agents/chat).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free