mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
langchain[patch]: Remove multiagent return_direct validation (#24419)
**Description:** When you use Agents with multi-input tool and some of these tools have `return_direct=True`, langchain thrown an error related to one validator. This change is implemented on [JS community](https://github.com/langchain-ai/langchainjs/pull/4643) as well **Issue**: This MR resolves #19843 **Dependencies:** None Co-authored-by: Jesus Martinez <jesusabraham.martinez@tyson.com> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
parent
74e3d796f1
commit
c1d1fc13c2
@ -1146,30 +1146,6 @@ class AgentExecutor(Chain):
|
||||
)
|
||||
return values
|
||||
|
||||
@root_validator(pre=False, skip_on_failure=True)
|
||||
def validate_return_direct_tool(cls, values: Dict) -> Dict:
|
||||
"""Validate that tools are compatible with agent.
|
||||
|
||||
Args:
|
||||
values: Values to validate.
|
||||
|
||||
Returns:
|
||||
Dict: Validated values.
|
||||
|
||||
Raises:
|
||||
ValueError: If tools that have `return_direct=True` are not allowed.
|
||||
"""
|
||||
agent = values["agent"]
|
||||
tools = values["tools"]
|
||||
if isinstance(agent, BaseMultiActionAgent):
|
||||
for tool in tools:
|
||||
if tool.return_direct:
|
||||
raise ValueError(
|
||||
"Tools that have `return_direct=True` are not allowed "
|
||||
"in multi-action agents"
|
||||
)
|
||||
return values
|
||||
|
||||
@root_validator(pre=True)
|
||||
def validate_runnable_agent(cls, values: Dict) -> Dict:
|
||||
"""Convert runnable to agent if passed in.
|
||||
|
Loading…
Reference in New Issue
Block a user