From 5b3bb3cabff7c8fc5c35031a0666a88260c1b55d Mon Sep 17 00:00:00 2001 From: Travis Dent Date: Wed, 15 Jan 2025 16:29:11 -0800 Subject: [PATCH] Move crewai tool decorator import to function where it is used to prevent import errors on `init`. --- agentstack/frameworks/crewai.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agentstack/frameworks/crewai.py b/agentstack/frameworks/crewai.py index 911bb728..c3b1fac9 100644 --- a/agentstack/frameworks/crewai.py +++ b/agentstack/frameworks/crewai.py @@ -8,11 +8,6 @@ from agentstack.agents import AgentConfig from agentstack.generation import asttools -try: - from crewai.tools import tool as _crewai_tool_decorator -except ImportError: - raise ValidationError("Could not import `crewai`. Is this an AgentStack CrewAI project?") - ENTRYPOINT: Path = Path('src/crew.py') @@ -330,6 +325,11 @@ def get_tool_callables(tool_name: str) -> list[Callable]: """ Get a tool implementations for use directly by a CrewAI agent. """ + try: + from crewai.tools import tool as _crewai_tool_decorator + except ImportError: + raise ValidationError("Could not import `crewai`. Is this an AgentStack CrewAI project?") + tool_funcs = [] tool_config = ToolConfig.from_tool_name(tool_name) for tool_func_name in tool_config.tools: