return_stopped_response() — langchain Function Reference
Architecture documentation for the return_stopped_response() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 083ac900_3458_2f92_cdad_5b192c460d85["return_stopped_response()"] 93ed7b23_f0e4_5732_b3ed_dccef0049b97["OpenAIFunctionsAgent"] 083ac900_3458_2f92_cdad_5b192c460d85 -->|defined in| 93ed7b23_f0e4_5732_b3ed_dccef0049b97 1beb0b73_e6d9_844c_11db_60fdd5087d3d["plan()"] 083ac900_3458_2f92_cdad_5b192c460d85 -->|calls| 1beb0b73_e6d9_844c_11db_60fdd5087d3d style 083ac900_3458_2f92_cdad_5b192c460d85 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/openai_functions_agent/base.py lines 170–211
def return_stopped_response(
self,
early_stopping_method: str,
intermediate_steps: list[tuple[AgentAction, str]],
**kwargs: Any,
) -> AgentFinish:
"""Return response when agent has been stopped due to max iterations.
Args:
early_stopping_method: The early stopping method to use.
intermediate_steps: Intermediate steps.
**kwargs: User inputs.
Returns:
AgentFinish.
Raises:
ValueError: If `early_stopping_method` is not `force` or `generate`.
ValueError: If `agent_decision` is not an AgentAction.
"""
if early_stopping_method == "force":
# `force` just returns a constant string
return AgentFinish(
{"output": "Agent stopped due to iteration limit or time limit."},
"",
)
if early_stopping_method == "generate":
# Generate does one final forward pass
agent_decision = self.plan(
intermediate_steps,
with_functions=False,
**kwargs,
)
if isinstance(agent_decision, AgentFinish):
return agent_decision
msg = f"got AgentAction with no functions provided: {agent_decision}"
raise ValueError(msg)
msg = (
"early_stopping_method should be one of `force` or `generate`, "
f"got {early_stopping_method}"
)
raise ValueError(msg)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does return_stopped_response() do?
return_stopped_response() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/openai_functions_agent/base.py.
Where is return_stopped_response() defined?
return_stopped_response() is defined in libs/langchain/langchain_classic/agents/openai_functions_agent/base.py at line 170.
What does return_stopped_response() call?
return_stopped_response() calls 1 function(s): plan.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free