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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/smolagents/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@
import numpy as np
import requests
from transformers.utils import (
is_soundfile_availble,
is_torch_available,
is_vision_available,
)

# for compatibility with mispelling old transformers versions (fixed in https://github.com/huggingface/transformers/pull/35030)
try:
from transformers.utils import is_soundfile_available
except ImportError:
from transformers.utils import is_soundfile_availble as is_soundfile_available

logger = logging.getLogger(__name__)

if is_vision_available():
Expand All @@ -41,7 +46,7 @@
else:
Tensor = object

if is_soundfile_availble():
if is_soundfile_available():
import soundfile as sf


Expand Down Expand Up @@ -189,7 +194,7 @@ class AgentAudio(AgentType, str):
def __init__(self, value, samplerate=16_000):
super().__init__(value)

if not is_soundfile_availble():
if not is_soundfile_available():
raise ImportError("soundfile must be installed in order to handle audio.")

self._path = None
Expand Down
4 changes: 2 additions & 2 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
require_vision,
)
from transformers.utils import (
is_soundfile_availble,
is_soundfile_available,
)

from smolagents.types import AgentAudio, AgentImage, AgentText

if is_soundfile_availble():
if is_soundfile_available():
import soundfile as sf


Expand Down
Loading