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

Compatibility fix for function names changed in new version of Transformers #94

Closed
wants to merge 2 commits into from

Conversation

sshell
Copy link

@sshell sshell commented Jan 6, 2025

There was a function that has been misspelled in transformers for a number of months that was recently fixed in main.
(is_soundfile_availble -> is_soundfile_available)

This mean smolagents won't work for people using current version of transformers installed straight from github (pip install -U git+https://github.com/huggingface/transformers)

Tried to come up with solution that will keep both versions working

> python smol.py
Traceback (most recent call last):
  File "C:\Users\User\Documents\github\security-article-reader\smol.py", line 1, in <module>
    from smolagents.agents import ToolCallingAgent
  File "C:\Users\User\AppData\Roaming\Python\Python312\site-packages\smolagents\agents.py", line 27, in <module>
    from .default_tools import FinalAnswerTool
  File "C:\Users\User\AppData\Roaming\Python\Python312\site-packages\smolagents\default_tools.py", line 34, in <module>    
    from .tools import TOOL_CONFIG_FILE, PipelineTool, Tool
  File "C:\Users\User\AppData\Roaming\Python\Python312\site-packages\smolagents\tools.py", line 52, in <module>
    from .types import ImageType, handle_agent_input_types, handle_agent_output_types
  File "C:\Users\User\AppData\Roaming\Python\Python312\site-packages\smolagents\types.py", line 24, in <module>
    from transformers.utils import (
ImportError: cannot import name 'is_soundfile_availble' from 'transformers.utils' (C:\Users\User\AppData\Roaming\Python\Python312\site-packages\transformers\utils\__init__.py). Did you mean: 'is_soundfile_available'?

> pip show transformers
Name: transformers
Version: 4.48.0.dev0

> pip show smolagents
Name: smolagents
Version: 1.1.0

Confirmed working after changes:

python .\smol.py

...──── New run ────...
What's the weather like in Paris?

This fix was only recently merged 3 days ago
huggingface/transformers#35030

@btucker
Copy link

btucker commented Jan 10, 2025

In case anyone's trying to get unstuck by this. I monkey patched this locally with:

    import transformers.utils
    import transformers.utils.import_utils

    # Fix for is_soundfile_available vs. is_soundfile_availble
    if hasattr(transformers.utils, 'is_soundfile_available'):
        transformers.utils.is_soundfile_availble = transformers.utils.is_soundfile_available
    elif hasattr(transformers.utils, 'is_soundfile_availble'):
        transformers.utils.is_soundfile_available = transformers.utils.is_soundfile_availble

@sshell
Copy link
Author

sshell commented Jan 11, 2025

Self-closing because @aymeric-roucher fixed this in #147
Thank you!

@sshell sshell closed this Jan 11, 2025
@aymeric-roucher
Copy link
Collaborator

Yes @sshell thank you for the fix! I was fighting installation issues and just removed the import of this function from transformers entirely. Moving forward in case of dependency-linked problems I'll always try to remove the dependency if it's not a big code overhead!

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.

3 participants