Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary self argument in GoogleSearchTool super() call #828

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

gael1130
Copy link
Contributor

@gael1130 gael1130 commented Feb 27, 2025

the GoogleSearchTool class had an error line 141:

super().init(self) instead of super().init(). I removed the self, which was causing the following issue when using it:

TypeError: GoogleSearchTool.__init__() got an unexpected keyword argument 'provider'

in the following code:

model = HfApiModel(
    "Qwen/Qwen2.5-Coder-32B-Instruct", provider="together", max_tokens=8096
)

web_agent = CodeAgent(
    model=model,
    tools=[
        GoogleSearchTool(provider="serpapi"),
        VisitWebpageTool(),
        calculate_cargo_travel_time,
    ],
    name="web_agent",
    description="Browses the web to find information",
    verbosity_level=0,
    max_steps=10,
)

from the multiagent_notebook of the agents course, unit 2.1, Multi-Agent Systems chapter

the GoogleSearchTool class had an error line 141: super().__init__(self) instead of super().__init__(). I removed the self, which was causing the following issue when using it: 
TypeError: GoogleSearchTool.__init__() got an unexpected keyword argument 'provider'

in the following code: 
model = HfApiModel(
    "Qwen/Qwen2.5-Coder-32B-Instruct", provider="together", max_tokens=8096
)

web_agent = CodeAgent(
    model=model,
    tools=[
        GoogleSearchTool(provider="serpapi"),
        VisitWebpageTool(),
        calculate_cargo_travel_time,
    ],
    name="web_agent",
    description="Browses the web to find information",
    verbosity_level=0,
    max_steps=10,
)

from the multiagent_notebook of the agents course, unit 2.1, Multi-Agent Systems chapter
@albertvillanova
Copy link
Member

albertvillanova commented Feb 28, 2025

@gael1130 thanks for the fix.

However, note that your fix will not fix your error: TypeError: GoogleSearchTool.__init__() got an unexpected keyword argument 'provider'.

  • Your error raises because you are using a version of smolagents that is prior to the PR that incorprated the provider argument:
  • To avoid the error, you need to remove the provider argument: Replace this line
    GoogleSearchTool(provider="serpapi"),
    with
    GoogleSearchTool(),

Alternatively, you need to install smolagents from the main branch (because #698 PR is not released yet).

@albertvillanova
Copy link
Member

Note that the self argument is ignored by the parent Tool.__init__, because all args are ignored.

Copy link
Member

@albertvillanova albertvillanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@albertvillanova albertvillanova changed the title Update default_tools.py to fix a bug on GoogleSearchTool class Remove unnecessary self argument in GoogleSearchTool super() call Feb 28, 2025
@albertvillanova albertvillanova merged commit 6abcb5f into huggingface:main Feb 28, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants