-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Describe the bug
When instantiating SpeechToTextTool
with a model parameter (e.g. SpeechToTextTool(model="openai/whisper-small"))
, the class raises a TypeError because the overridden __new__
method incorrectly forwards *args
and **kwargs
to super().__new__()
, which does not expect these arguments.
Code to reproduce the error
from smolagents.default_tools import SpeechToTextTool
speech_to_text_tool = SpeechToTextTool(model="openai/whisper-small")
Error logs (if any)
Traceback (most recent call last):
File "/path/to/project/bug_demo.py", line 3, in
speech_to_text_tool = SpeechToTextTool(model="openai/whisper-small")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/project/venv/lib/python3.12/site-packages/smolagents/default_tools.py", line 499, in new
return super().new(cls, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object.new() takes exactly one argument (the type to instantiate)
Expected behavior
The instance of SpeechToTextTool
should be created successfully when passing keyword arguments like model=...
or other arguments accepted in PipelineTool.__init__
method without raising a TypeError.
Packages version:
smolagents==1.17.0
Additional context
The issue can be fixed by not forwarding *args
and **kwargs
in __new__
, i.e., changing the return line to:
return super().__new__(cls)
This allows instance initialization with parameters to proceed in __init__
without breaking instance creation.