langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.51k stars 14.81k forks source link

Issue: The purpose to validate_tools_single_input in CHAT_CONVERSATIONAL_REACT_DESCRIPTION agent #14329

Closed ChengyangDu closed 6 months ago

ChengyangDu commented 9 months ago

Issue you'd like to raise.

Cannot figure out why validate_tools_single_input is necessary. I've tried to adopt multi-inputs tools in CHAT_CONVERSATIONAL_REACT_DESCRIPTION agents by just commenting out the implementation of such function. Everything seemed fun. So what's the purpose of such design, and if it is possible to use multi-inputs tools in a more flexible setup?

Suggestion:

No response

dosubot[bot] commented 9 months ago

🤖

Hello @ChengyangDu,

I'm delighted to meet you! I'm Dosu, an AI bot here to assist you with your questions, help solve bugs, and guide you on how to contribute. While we wait for a human maintainer to join us, feel free to ask me anything. I'm here to help make your interaction with the LangChain repository as smooth as possible. Let's get started!

The validate_tools_single_input function in the libs/langchain/langchain/agents/utils.py file is used to validate whether the tools being used in the LangChain application are designed to handle single inputs. This function is necessary when you want to ensure that all tools being used in a specific class or part of your application are designed to handle single inputs. If you want to use multi-input tools in a more flexible setup, you would need to modify or bypass this function, as it currently raises an error when encountering a multi-input tool. Here is the code snippet for reference:

def validate_tools_single_input(class_name: str, tools: Sequence[BaseTool]) -> None:
    """Validate tools for single input."""
    for tool in tools:
        if not tool.is_single_input:
            raise ValueError(
                f"{class_name} does not support multi-input tool {tool.name}."
            )

(Source: libs/langchain/langchain/agents/utils.py)

As for the CHAT_CONVERSATIONAL_REACT_DESCRIPTION agent, it is not mentioned in the provided context. Therefore, I cannot provide information about its role in the LangChain framework.

Regarding your question about similar issues, there was a similar issue titled ValueError: ZeroShotAgent does not support multi-input tool Calculator. which was last updated on September 09, 2023. The suggested solution was to downgrade LangChain to version v0.0.147 or use a different AgentType that supports multi-input tools, such as AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION.

I hope this information helps! If you have any other questions, feel free to ask.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

ChengyangDu commented 9 months ago

I'd like to figure out the reason why such limitation exists, in order to make right coding decision.