refactor: remove token validation from EnterpriseActionKitToolAdapter… (#331)

* refactor: remove token validation from EnterpriseActionKitToolAdapter and CrewaiEnterpriseTools

This commit simplifies the initialization of the EnterpriseActionKitToolAdapter and CrewaiEnterpriseTools by removing the explicit validation for the enterprise action token. The token can now be set to None without raising an error, allowing for more flexible usage.

* added loggers for monitoring

* fixed typo
This commit is contained in:
Lorenze Jay
2025-06-14 12:21:18 -07:00
committed by GitHub
parent dc2d4af8ea
commit 5a99f07765
2 changed files with 6 additions and 8 deletions

View File

@@ -125,8 +125,6 @@ class EnterpriseActionKitToolAdapter:
enterprise_action_kit_project_id: str = ENTERPRISE_ACTION_KIT_PROJECT_ID,
):
"""Initialize the adapter with an enterprise action token."""
if not enterprise_action_token:
raise ValueError("enterprise_action_token is required")
self.enterprise_action_token = enterprise_action_token
self._actions_schema = {}

View File

@@ -4,9 +4,12 @@ Crewai Enterprise Tools
import os
import typing as t
import logging
from crewai.tools import BaseTool
from crewai_tools.adapters.enterprise_adapter import EnterpriseActionKitToolAdapter
logger = logging.getLogger(__name__)
def CrewaiEnterpriseTools(
enterprise_token: t.Optional[str] = None,
@@ -18,7 +21,7 @@ def CrewaiEnterpriseTools(
Args:
enterprise_token: The token for accessing enterprise actions.
If not provided, will try to use CREWAI_ENTEPRISE_TOOLS_TOKEN env var.
If not provided, will try to use CREWAI_ENTERPRISE_TOOLS_TOKEN env var.
actions_list: Optional list of specific tool names to include.
If provided, only tools with these names will be returned.
@@ -26,11 +29,8 @@ def CrewaiEnterpriseTools(
A list of BaseTool instances for enterprise actions
"""
if enterprise_token is None:
enterprise_token = os.environ.get("CREWAI_ENTEPRISE_TOOLS_TOKEN")
if enterprise_token is None:
raise ValueError(
"No enterprise token provided. Please provide a token or set the CREWAI_ENTEPRISE_TOOLS_TOKEN environment variable."
)
enterprise_token = os.environ.get("CREWAI_ENTERPRISE_TOOLS_TOKEN")
logger.warning("No enterprise token provided")
adapter_kwargs = {"enterprise_action_token": enterprise_token}