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 1fab5269_943e_e7a5_4729_eee14e04448a["base.py"] cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] 1fab5269_943e_e7a5_4729_eee14e04448a --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 1fab5269_943e_e7a5_4729_eee14e04448a --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 b19a8b7e_fbee_95b1_65b8_509a1ed3cad7["langchain_core._api"] 1fab5269_943e_e7a5_4729_eee14e04448a --> b19a8b7e_fbee_95b1_65b8_509a1ed3cad7 ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"] 1fab5269_943e_e7a5_4729_eee14e04448a --> ba43b74d_3099_7e1c_aac3_cf594720469e e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"] 1fab5269_943e_e7a5_4729_eee14e04448a --> e6b4f61e_7b98_6666_3641_26b069517d4a 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c["langchain_core.runnables"] 1fab5269_943e_e7a5_4729_eee14e04448a --> 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c 43d88577_548b_2248_b01b_7987bae85dcc["langchain_core.tools"] 1fab5269_943e_e7a5_4729_eee14e04448a --> 43d88577_548b_2248_b01b_7987bae85dcc 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 1fab5269_943e_e7a5_4729_eee14e04448a --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] 1fab5269_943e_e7a5_4729_eee14e04448a --> 91721f45_4909_e489_8c1f_084f8bd87145 e160f068_75de_4342_6673_9969b919de85["langchain_classic.agents.agent"] 1fab5269_943e_e7a5_4729_eee14e04448a --> e160f068_75de_4342_6673_9969b919de85 8bc2eee7_b040_0edd_0172_48295cb3fb89["langchain_classic.agents.agent_types"] 1fab5269_943e_e7a5_4729_eee14e04448a --> 8bc2eee7_b040_0edd_0172_48295cb3fb89 86bb3cc5_a04d_0230_26de_553f2b190764["langchain_classic.agents.format_scratchpad"] 1fab5269_943e_e7a5_4729_eee14e04448a --> 86bb3cc5_a04d_0230_26de_553f2b190764 78d099f6_0faa_078b_41b8_fec102371356["langchain_classic.agents.self_ask_with_search.output_parser"] 1fab5269_943e_e7a5_4729_eee14e04448a --> 78d099f6_0faa_078b_41b8_fec102371356 ff655912_af12_ebda_733a_d9778fcc5c80["langchain_classic.agents.self_ask_with_search.prompt"] 1fab5269_943e_e7a5_4729_eee14e04448a --> ff655912_af12_ebda_733a_d9778fcc5c80 style 1fab5269_943e_e7a5_4729_eee14e04448a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Chain that does self-ask with search."""
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
from langchain_core._api import deprecated
from langchain_core.language_models import BaseLanguageModel
from langchain_core.prompts import BasePromptTemplate
from langchain_core.runnables import Runnable, RunnablePassthrough
from langchain_core.tools import BaseTool, Tool
from pydantic import Field
from typing_extensions import override
from langchain_classic.agents.agent import Agent, AgentExecutor, AgentOutputParser
from langchain_classic.agents.agent_types import AgentType
from langchain_classic.agents.format_scratchpad import format_log_to_str
from langchain_classic.agents.self_ask_with_search.output_parser import (
SelfAskOutputParser,
)
from langchain_classic.agents.self_ask_with_search.prompt import PROMPT
from langchain_classic.agents.utils import validate_tools_single_input
if TYPE_CHECKING:
from langchain_community.utilities.google_serper import GoogleSerperAPIWrapper
from langchain_community.utilities.searchapi import SearchApiAPIWrapper
from langchain_community.utilities.serpapi import SerpAPIWrapper
@deprecated("0.1.0", alternative="create_self_ask_with_search", removal="1.0")
class SelfAskWithSearchAgent(Agent):
"""Agent for the self-ask-with-search paper."""
output_parser: AgentOutputParser = Field(default_factory=SelfAskOutputParser)
@classmethod
@override
def _get_default_output_parser(cls, **kwargs: Any) -> AgentOutputParser:
return SelfAskOutputParser()
@property
def _agent_type(self) -> str:
"""Return Identifier of an agent type."""
return AgentType.SELF_ASK_WITH_SEARCH
@classmethod
@override
def create_prompt(cls, tools: Sequence[BaseTool]) -> BasePromptTemplate:
"""Prompt does not depend on tools."""
return PROMPT
@classmethod
def _validate_tools(cls, tools: Sequence[BaseTool]) -> None:
validate_tools_single_input(cls.__name__, tools)
super()._validate_tools(tools)
if len(tools) != 1:
msg = f"Exactly one tool must be specified, but got {tools}"
raise ValueError(msg)
tool_names = {tool.name for tool in tools}
// ... (157 more lines)
Domain
Subdomains
Dependencies
- collections.abc
- langchain_classic.agents.agent
- langchain_classic.agents.agent_types
- langchain_classic.agents.format_scratchpad
- langchain_classic.agents.self_ask_with_search.output_parser
- langchain_classic.agents.self_ask_with_search.prompt
- langchain_classic.agents.utils
- langchain_community.utilities.google_serper
- langchain_community.utilities.searchapi
- langchain_community.utilities.serpapi
- langchain_core._api
- langchain_core.language_models
- langchain_core.prompts
- langchain_core.runnables
- 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 functions are defined in base.py?
base.py defines 2 function(s): create_self_ask_with_search_agent, langchain_community.
What does base.py depend on?
base.py imports 18 module(s): collections.abc, langchain_classic.agents.agent, langchain_classic.agents.agent_types, langchain_classic.agents.format_scratchpad, langchain_classic.agents.self_ask_with_search.output_parser, langchain_classic.agents.self_ask_with_search.prompt, langchain_classic.agents.utils, langchain_community.utilities.google_serper, and 10 more.
Where is base.py in the architecture?
base.py is located at libs/langchain/langchain_classic/agents/self_ask_with_search/base.py (domain: AgentOrchestration, subdomain: ActionLogic, directory: libs/langchain/langchain_classic/agents/self_ask_with_search).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free