mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
replace print by logger
This commit is contained in:
@@ -10,7 +10,7 @@ from crewai_tools.tools.crewai_platform_tools.misc import (
|
|||||||
get_platform_api_base_url,
|
get_platform_api_base_url,
|
||||||
get_platform_integration_token,
|
get_platform_integration_token,
|
||||||
)
|
)
|
||||||
|
from crewai.utilities.logger import Logger
|
||||||
|
|
||||||
class CrewaiPlatformToolBuilder:
|
class CrewaiPlatformToolBuilder:
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -20,6 +20,7 @@ class CrewaiPlatformToolBuilder:
|
|||||||
self._apps = apps
|
self._apps = apps
|
||||||
self._actions_schema = {} # type: ignore[var-annotated]
|
self._actions_schema = {} # type: ignore[var-annotated]
|
||||||
self._tools = None
|
self._tools = None
|
||||||
|
self._logger = Logger(verbose=True)
|
||||||
|
|
||||||
def tools(self) -> list[BaseTool]:
|
def tools(self) -> list[BaseTool]:
|
||||||
if self._tools is None:
|
if self._tools is None:
|
||||||
@@ -30,9 +31,7 @@ class CrewaiPlatformToolBuilder:
|
|||||||
def _fetch_actions(self):
|
def _fetch_actions(self):
|
||||||
actions_url = f"{get_platform_api_base_url()}/actions"
|
actions_url = f"{get_platform_api_base_url()}/actions"
|
||||||
headers = {"Authorization": f"Bearer {get_platform_integration_token()}"}
|
headers = {"Authorization": f"Bearer {get_platform_integration_token()}"}
|
||||||
print("->>>>> headers:", headers)
|
self._logger.log("info", f"Fetch actions: {actions_url}, {headers}, {','.join(self._apps)}")
|
||||||
print("->>>>> actions_url:", actions_url)
|
|
||||||
print("->>>>> apps:", ",".join(self._apps))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
@@ -43,8 +42,7 @@ class CrewaiPlatformToolBuilder:
|
|||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("->>>>> error in _fetch_actions")
|
self._logger.log("error", f"Error fetching actions: {e!s}")
|
||||||
print("->>>>> error:", e)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -640,14 +640,13 @@ class Agent(BaseAgent):
|
|||||||
|
|
||||||
def get_platform_tools(self, apps: list[PlatformAppOrAction]) -> list[BaseTool]:
|
def get_platform_tools(self, apps: list[PlatformAppOrAction]) -> list[BaseTool]:
|
||||||
try:
|
try:
|
||||||
print("->>>>> start get_platform_tools:", apps)
|
self._logger.log("info", f"Start get_platform_tools: {apps}")
|
||||||
from crewai_tools import (
|
from crewai_tools import (
|
||||||
CrewaiPlatformTools,
|
CrewaiPlatformTools,
|
||||||
)
|
)
|
||||||
|
|
||||||
return CrewaiPlatformTools(apps=apps)
|
return CrewaiPlatformTools(apps=apps)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("->>>>> error in get_platform_tools")
|
|
||||||
self._logger.log("error", f"Error getting platform tools: {e!s}")
|
self._logger.log("error", f"Error getting platform tools: {e!s}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user