SelfAskWithSearchAgent Class — langchain Architecture
Architecture documentation for the SelfAskWithSearchAgent class in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f0511fe2_9275_28de_22f0_35e3fb0e4ae2["SelfAskWithSearchAgent"] 37fcc3f3_2798_3648_915c_2bffdd19bff7["Agent"] f0511fe2_9275_28de_22f0_35e3fb0e4ae2 -->|extends| 37fcc3f3_2798_3648_915c_2bffdd19bff7 1fab5269_943e_e7a5_4729_eee14e04448a["base.py"] f0511fe2_9275_28de_22f0_35e3fb0e4ae2 -->|defined in| 1fab5269_943e_e7a5_4729_eee14e04448a cfee35cb_33fe_0726_e9fb_29f524d9567d["_get_default_output_parser()"] f0511fe2_9275_28de_22f0_35e3fb0e4ae2 -->|method| cfee35cb_33fe_0726_e9fb_29f524d9567d 6dab5776_e192_4e13_7aab_2dd670d6fb92["_agent_type()"] f0511fe2_9275_28de_22f0_35e3fb0e4ae2 -->|method| 6dab5776_e192_4e13_7aab_2dd670d6fb92 09e5caa9_83be_b858_6bbe_d97e5ec7c784["create_prompt()"] f0511fe2_9275_28de_22f0_35e3fb0e4ae2 -->|method| 09e5caa9_83be_b858_6bbe_d97e5ec7c784 46289c41_3f5e_312b_c9fb_76857722ca25["_validate_tools()"] f0511fe2_9275_28de_22f0_35e3fb0e4ae2 -->|method| 46289c41_3f5e_312b_c9fb_76857722ca25 dd819bff_45c3_1aed_7f91_9eca7a6ef926["observation_prefix()"] f0511fe2_9275_28de_22f0_35e3fb0e4ae2 -->|method| dd819bff_45c3_1aed_7f91_9eca7a6ef926 bc6f03bc_fbb8_fd47_a469_625ff046ab9c["llm_prefix()"] f0511fe2_9275_28de_22f0_35e3fb0e4ae2 -->|method| bc6f03bc_fbb8_fd47_a469_625ff046ab9c
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/self_ask_with_search/base.py lines 32–73
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}
if tool_names != {"Intermediate Answer"}:
msg = f"Tool name should be Intermediate Answer, got {tool_names}"
raise ValueError(msg)
@property
def observation_prefix(self) -> str:
"""Prefix to append the observation with."""
return "Intermediate answer: "
@property
def llm_prefix(self) -> str:
"""Prefix to append the LLM call with."""
return ""
Extends
Source
Frequently Asked Questions
What is the SelfAskWithSearchAgent class?
SelfAskWithSearchAgent is a class in the langchain codebase, defined in libs/langchain/langchain_classic/agents/self_ask_with_search/base.py.
Where is SelfAskWithSearchAgent defined?
SelfAskWithSearchAgent is defined in libs/langchain/langchain_classic/agents/self_ask_with_search/base.py at line 32.
What does SelfAskWithSearchAgent extend?
SelfAskWithSearchAgent extends Agent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free