ModuleNotFoundError: No module named 'transformers.agents'
Hi,I am testing Transformer Agents but it seems like the agent is not working.Code###################################################################from transformers import HfAgentapi_token = “my personal api token”agent = HfAgent(“https://api-inference.huggingface.co/models/bigcode/starcoder2-15b”, token=api_token)print(“StarCoder is initialized”)boat = agent.run(“Generate an image of a boat in the water”)print(boat)###################################################################Error Code:Traceback (most recent call last):File “main.py”, line 13, inboat = agent.run(“Generate an image of a boat in the water”)File “/Users/yoojinchoi/miniforge3/envs/agent/lib/python3.8/site-packages/transformers/tools/agents.py”, line 349, in runself.cached_tools = resolve_tools(code, self.toolbox, remote=remote, cached_tools=self.cached_tools)File “/Users/yoojinchoi/miniforge3/envs/agent/lib/python3.8/site-packages/transformers/tools/agents.py”, line 141, in resolve_toolsresolved_tools[name] = load_tool(task_or_repo_id, remote=_remote)File “/Users/yoojinchoi/miniforge3/envs/agent/lib/python3.8/site-packages/transformers/tools/base.py”, line 690, in load_toolreturn Tool.from_hub(task_or_repo_id, model_repo_id=model_repo_id, token=token, remote=remote, **kwargs)File “/Users/yoojinchoi/miniforge3/envs/agent/lib/python3.8/site-packages/transformers/tools/base.py”, line 262, in from_hubtool_class = get_class_from_dynamic_module(tool_class, repo_id, use_auth_token=token, **hub_kwargs)File “/Users/yoojinchoi/miniforge3/envs/agent/lib/python3.8/site-packages/transformers/dynamic_module_utils.py”, line 497, in get_class_from_dynamic_modulereturn get_class_in_module(class_name, final_module.replace(“.py”, “”))File “/Users/yoojinchoi/miniforge3/envs/agent/lib/python3.8/site-packages/transformers/dynamic_module_utils.py”, line 199, in get_class_in_modulemodule = importlib.import_module(module_path)File “/Users/yoojinchoi/miniforge3/envs/agent/lib/python3.8/importlib/init.py”, line 127, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File “”, line 1014, in _gcd_importFile “”, line 991, in _find_and_loadFile “”, line 975, in _find_and_load_unlockedFile “”, line 671, in _load_unlockedFile “”, line 843, in exec_moduleFile “”, line 219, in _call_with_frames_removedFile “/Users/yoojinchoi/.cache/huggingface/modules/transformers_modules/huggingface-tools/text-to-image/5109976614257b9fb49408d8cc5364e77bb57894/text_to_image.py”, line 1, infrom transformers.agents.tools import ToolModuleNotFoundError: No module named ‘transformers.agents’###################################################################I did install transformer by following this steps:Medium – 30 Sep 22Huggingface Installation on Apple Silicon 2022 (M1/Pro/Max/Ultra/M2)The new MacBook’s, with their powerful processors, are spectacular machines with great potential as a portable Machines for on-the-go…Reading time: 3 min readI made sure the arch is i386.Could you please help me ? I really want to build open-sourced agents without OpanAI’s tool and I thought Transformer Agent would be a great tool to give it a try.Thank you!
2024-05-13T20:14:14Z
The 2.0 agent is not main branch yet.You can get early access like this : pip install “git+https://github.com/huggingface/transformers.git#egg=transformers[agents]”
2024-05-16T01:02:47Z
Hey there!I was in the same boat with the error ModuleNotFoundError: No module named ‘transformers.agents’The reason is because there has been a refactor of agents! See here:github.comhuggingface/transformers/blob/main/docs/source/en/main_classes/agent.md<!--Copyright 2023 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->

# Agents & Tools

<Tip warning={true}>This file has been truncated.show originalgithub.com/huggingface/transformersReboot Agentshuggingface:main←huggingface:agentsopened09:56AM - 22 Apr 24 UTCaymeric-roucher+3675-5419# What does this PR do?

Reboot agents in transformers!

cc @LysandreJikLooks like we are going need to refactor along with these changes or use an old version. Hope this helped you!