joaomdmoura / crewAI-tools

MIT License
414 stars 129 forks source link

TypeError: ScrapeWebsiteTool._run() takes 1 positional argument but 2 were given #10

Open geverit4 opened 3 months ago

geverit4 commented 3 months ago

The only tool I can get to work is SerperDevTool. Other tools like ScrapeWebsiteTool and WebsiteSearchTool do not work.

I've tried running the tool_instance directly and running it from within the context of an Agent as well. Every method throws the

TypeError: ScrapeWebsiteTool._run() takes 1 positional argument but 2 were given"

exception

from langchain.tools import Tool
from crewai_tools import ScrapeWebsiteTool

tool_instance=ScrapeWebsiteTool()

tool = Tool(
    name=tool_instance.name,
    func=tool_instance.run,
    description=tool_instance.description
)
tool.run('https://en.wikipedia.org/wiki/Clearwater%2C_Florida')

That is the bare minimum to simulate running a tool. They all throw this error;

{
    "name": "TypeError",
    "message": "ScrapeWebsiteTool._run() takes 1 positional argument but 2 were given",
    "stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[19], line 14
      7 tool_instance=ScrapeWebsiteTool()
      9 tool = Tool(
     10     name=tool_instance.name,
     11     func=tool_instance.run,
     12     description=tool_instance.description
     13 )
---> 14 tool.run('https://en.wikipedia.org/wiki/Clearwater%2C_Florida')

File /workspace/development/frappe-bench/env/lib/python3.11/site-packages/langchain_core/tools.py:419, in BaseTool.run(self, tool_input, verbose, start_color, color, callbacks, tags, metadata, run_name, **kwargs)
    417 except (Exception, KeyboardInterrupt) as e:
    418     run_manager.on_tool_error(e)
--> 419     raise e
    420 else:
    421     run_manager.on_tool_end(
    422         str(observation), color=color, name=self.name, **kwargs
    423     )

File /workspace/development/frappe-bench/env/lib/python3.11/site-packages/langchain_core/tools.py:376, in BaseTool.run(self, tool_input, verbose, start_color, color, callbacks, tags, metadata, run_name, **kwargs)
    373     parsed_input = self._parse_input(tool_input)
    374     tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input)
    375     observation = (
--> 376         self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
    377         if new_arg_supported
    378         else self._run(*tool_args, **tool_kwargs)
    379     )
    380 except ValidationError as e:
    381     if not self.handle_validation_error:

File /workspace/development/frappe-bench/env/lib/python3.11/site-packages/langchain_core/tools.py:584, in Tool._run(self, run_manager, *args, **kwargs)
    575 if self.func:
    576     new_argument_supported = signature(self.func).parameters.get(\"callbacks\")
    577     return (
    578         self.func(
    579             *args,
    580             callbacks=run_manager.get_child() if run_manager else None,
    581             **kwargs,
    582         )
    583         if new_argument_supported
--> 584         else self.func(*args, **kwargs)
    585     )
    586 raise NotImplementedError(\"Tool does not support sync\")

File /workspace/development/frappe-bench/env/lib/python3.11/site-packages/crewai_tools/tools/base_tool.py:30, in BaseTool.run(self, *args, **kwargs)
     24 def run(
     25     self,
     26     *args: Any,
     27     **kwargs: Any,
     28 ) -> Any:
     29     print(f\"Using Tool: {self.name}\")
---> 30     return self._run(*args, **kwargs)

TypeError: ScrapeWebsiteTool._run() takes 1 positional argument but 2 were given"
}
haveamission commented 2 months ago

I'm seeing similar issues with SerperDevTool

joaomdmoura commented 2 months ago

Oh I think the issue. with your example is how you're setting it up the correct way would be:

from langchain.tools import Tool
from crewai_tools import ScrapeWebsiteTool

tool=ScrapeWebsiteTool()
tool.run(website_url='https://en.wikipedia.org/wiki/Clearwater%2C_Florida')
joaomdmoura commented 2 months ago

We are pushing a few improvements for serper tonight