mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
fix: Improve agentops initialization with better validation and logging
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -253,10 +253,15 @@ class Crew(BaseModel):
|
|||||||
# Initialize agentops if available and API key is present
|
# Initialize agentops if available and API key is present
|
||||||
if agentops:
|
if agentops:
|
||||||
api_key = os.getenv("AGENTOPS_API_KEY")
|
api_key = os.getenv("AGENTOPS_API_KEY")
|
||||||
if api_key:
|
if api_key and api_key.strip(): # Validate API key
|
||||||
try:
|
try:
|
||||||
agentops.init(api_key)
|
agentops.init(api_key)
|
||||||
except Exception as e:
|
self._logger.log(
|
||||||
|
"info",
|
||||||
|
"Successfully initialized agentops",
|
||||||
|
color="green"
|
||||||
|
)
|
||||||
|
except (ConnectionError, ValueError) as e:
|
||||||
self._logger.log(
|
self._logger.log(
|
||||||
"warning",
|
"warning",
|
||||||
f"Failed to initialize agentops: {e}",
|
f"Failed to initialize agentops: {e}",
|
||||||
|
|||||||
Reference in New Issue
Block a user