I am facing an issue with the tools uses in the agent. PFB the code that I am trying to use -
I have imported the relevant packages needed for the tools.
Creating Agents
lead_data_agent = Agent(
config=lead_agents_config[‘lead_data_agent’],
tools=[SerperDevTool(), ScrapeWebsiteTool()],
llm=llm
)
AttributeError: ‘StructuredTool’ object has no attribute ‘model_fields’
I am tried this using multiple versions of crewAI and tools package. the last one used are
crew 0.9.2
crewai 0.86.0
crewai-tools 0.25.5
I am facing the same issue , has anyone resolved this ?
I am having the same issue trying to run the notebook from this official lesson by crew ai locally: Practical Multi AI Agents and Advanced Use Cases with crewAI - DeepLearning.AI
crewai==0.75.0
crewai-tools==0.12.1
Here’s the full traceback:
--------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 2
1 # Creating Agents
----> 2 suggestion_generation_agent = Agent(
3 config=agents_config['suggestion_generation_agent'],
4 tools=[csv_tool]
5 )
7 reporting_agent = Agent(
8 config=agents_config['reporting_agent'],
9 tools=[csv_tool]
10 )
12 chart_generation_agent = Agent(
13 config=agents_config['chart_generation_agent'],
14 allow_code_execution=False
15 )
[... skipping hidden 1 frame]
File ~/anaconda3/envs/crewai-env-2/lib/python3.11/site-packages/crewai/agent.py:174, in Agent.post_init_setup(self)
167 self.function_calling_llm = LLM(
168 model=getattr(self.function_calling_llm, "model_name", None)
169 or getattr(self.function_calling_llm, "deployment_name", None)
170 or str(self.function_calling_llm)
171 )
173 if not self.agent_executor:
--> 174 self._setup_agent_executor()
176 return self
File ~/anaconda3/envs/crewai-env-2/lib/python3.11/site-packages/crewai/agent.py:181, in Agent._setup_agent_executor(self)
179 if not self.cache_handler:
180 self.cache_handler = CacheHandler()
--> 181 self.set_cache_handler(self.cache_handler)
File ~/anaconda3/envs/crewai-env-2/lib/python3.11/site-packages/crewai/agents/agent_builder/base_agent.py:262, in BaseAgent.set_cache_handler(self, cache_handler)
260 self.cache_handler = cache_handler
261 self.tools_handler.cache = cache_handler
--> 262 self.create_agent_executor()
File ~/anaconda3/envs/crewai-env-2/lib/python3.11/site-packages/crewai/agent.py:292, in Agent.create_agent_executor(self, tools, task)
275 if self.response_template:
276 stop_words.append(
277 self.response_template.split("{{ .Response }}")[1].strip()
278 )
280 self.agent_executor = CrewAgentExecutor(
281 llm=self.llm,
282 task=task,
283 agent=self,
284 crew=self.crew,
285 tools=parsed_tools,
286 prompt=prompt,
287 original_tools=tools,
288 stop_words=stop_words,
289 max_iter=self.max_iter,
290 tools_handler=self.tools_handler,
291 tools_names=self.__tools_names(parsed_tools),
--> 292 tools_description=self._render_text_description_and_args(parsed_tools),
293 step_callback=self.step_callback,
294 function_calling_llm=self.function_calling_llm,
295 respect_context_window=self.respect_context_window,
296 request_within_rpm_limit=(
297 self._rpm_controller.check_or_wait if self._rpm_controller else None
298 ),
299 callbacks=[TokenCalcHandler(self._token_process)],
300 )
File ~/anaconda3/envs/crewai-env-2/lib/python3.11/site-packages/crewai/agent.py:397, in Agent._render_text_description_and_args(self, tools)
395 tool_strings = []
396 for tool in tools:
--> 397 args_schema = str(tool.model_fields)
398 if hasattr(tool, "func") and tool.func:
399 sig = signature(tool.func)
AttributeError: 'StructuredTool' object has no attribute 'model_fields'
Please help!