Skip to content

Commit f274968

Browse files
committed
fix: make transformers import optional
The 'transformers' library is not listed in requirements.txt but was imported at the top level in _utils.py, causing ImportError in environments where it is not installed (e.g., CI). This commit wraps the import in a try-except block to make it optional, mirroring the logic in TokenizerWrapper. Signed-off-by: majiayu000 <1835304752@qq.com>
1 parent c026478 commit f274968

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nano_graphrag/_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import tiktoken
1515

1616

17-
from transformers import AutoTokenizer
17+
try:
18+
from transformers import AutoTokenizer
19+
except ImportError:
20+
AutoTokenizer = None
1821

1922
logger = logging.getLogger("nano-graphrag")
2023
logging.getLogger("neo4j").setLevel(logging.ERROR)

0 commit comments

Comments
 (0)