langchain: ValueError: ZeroShotAgent does not support multi-input tool Calculator.

There is an error when i tried to use this code.

tools = load_tools(['llm-math', 'python_repl'], llm)
agent = initialize_agent(tools, agent="zero-shot-react-description", llm=llm)

Looks like because of #3684 checking if len(self.args) == 1: in self.is_single_input. But, self.args of llm-math is

{'args': {'title': 'Args', 'type': 'array', 'items': {}},
 'kwargs': {'title': 'Kwargs', 'type': 'object'}}

So, self.is_single_input return False

Is there a way to get single input llm-math?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 29 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @BankNatchapol

I think its related to the recent releases.

Installing v0.0.147 would resolve the issue. Do the following

pip install --force-reinstall -v langchain==v0.0.147

In the meantime someone needs to fix this bug.

I’ve had the same problem with all agent types. The _validate_tools method is the problem. Commenting out this line, the agent resumes work: https://github.com/hwchase17/langchain/blob/v0.0.152/langchain/agents/agent.py#L478

I still can’t figure out why. Does anyone know why the agent shouldn’t support a multiple input tool?

I tried with ConversationalAgent with a RetrivalQA tool that needs {context} and {quary} inputs.

Got it. As a new user, it was not immediately clear which agents were the right ones to use. Maybe the old ones should print a deprecation warning if they are used?

I don’t quite understand why the multi-input tools are supposed to not work with the older agents. They were working before, and are still working fine with this quick hack that just turns the validation into a no-op:

from langchain.agents.conversational_chat.base import ConversationalChatAgent

ConversationalChatAgent._validate_tools = lambda *_, **__: ...

Out of curiosity @vowelparrot, why do you say that they don’t work? The new structured tools look cool, but afaict I can’t use them yet, since my use case requires a chat agent with a conversation history, and the only new structured tool STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION doesn’t support chat history.

Thanks for your help. It is not working as expected with AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION

As it does not use my API even when I prompt it otherwise by modifying the template.

I have downgraded langchain to v0.0.147 for now.

I created a PR here that removes the restrictive checking of multi-input in the Agent base class. Will need reviewers to +1 and merge.

I am seeing this issue in the latest version (langchain==0.0.216). Why was this issue closed?

>>> agent = initialize_agent(tools, chat_llm, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rb013z/venvs/hackathon39/lib/python3.9/site-packages/langchain/agents/initialize.py", line 57, in initialize_agent
    agent_obj = agent_cls.from_llm_and_tools(
  File "/Users/rb013z/venvs/hackathon39/lib/python3.9/site-packages/langchain/agents/chat/base.py", line 112, in from_llm_and_tools
    cls._validate_tools(tools)
  File "/Users/rb013z/venvs/hackathon39/lib/python3.9/site-packages/langchain/agents/chat/base.py", line 62, in _validate_tools
    validate_tools_single_input(class_name=cls.__name__, tools=tools)
  File "/Users/rb013z/venvs/hackathon39/lib/python3.9/site-packages/langchain/agents/utils.py", line 10, in validate_tools_single_input
    raise ValueError(
ValueError: ChatAgent does not support multi-input tool calculate_discount.

EDIT: It looks like using a different AgentType works. agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION

Thanks, I was writing a custom tool that takes multiple arguments and calls an API. I am using the agent: 'chat-conversational-react-description'

What am I doing wrong?

class OrgSearchTool(BaseTool):
    name = "Get Organization Details"
    description = "Useful when searching for information about an organization or company for a give name and website."

    def _run(self, name: str, website: str):
        from api import search_org
        r = search_org(name, website)
        if len(r) > 4000:
            r = r[:4000]
        return r
    
    def _arun(self, webpage: str):
        raise NotImplementedError("This tool does not support async")

org_search = OrgSearchTool()

tools = [search, org_search]

As a LangChain newcomer, I just got hit by this one as well.

The tools documentation shows examples of multi-input tools without mentioning agent types (e.g. here).

Yes the playwright and other structured tools will be compatible with a new agent. Previous agents’ format instructions and parsers don’t work well with more complex signatures

Ok so which agent should I use then? Any examples?