From 94cce06044af904a8f794511449abf250dc64c2f Mon Sep 17 00:00:00 2001 From: Minura Punchihewa Date: Fri, 3 Jan 2025 11:08:38 +0530 Subject: [PATCH] updated the initialization logic to allow the API key to be passed as env var --- src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py b/src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py index 222271d7f..1059d0053 100644 --- a/src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py +++ b/src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py @@ -1,3 +1,4 @@ +import os import secrets from typing import Any, Dict, List, Optional, Text, Type @@ -36,7 +37,13 @@ class AIMindTool(BaseTool): "`minds_sdk` package not found, please run `pip install minds-sdk`" ) - minds_client = Client(api_key=api_key) + if os.getenv("MINDS_API_KEY"): + self.api_key = os.getenv("MINDS_API_KEY") + + if self.api_key is None: + raise ValueError("A Minds API key is required to use the AIMind Tool.") + + minds_client = Client(api_key=self.api_key) # Convert the datasources to DatabaseConfig objects. datasources = []