You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"'TEAM_API_KEY' has not been set properly and is empty. For help, please refer to the documentation (https://github.com/aixplain/aixplain#api-key-setup)"
34
-
)
35
30
31
+
defvalidate_api_keys():
32
+
"""Centralized API key validation function - single source of truth.
"Conflicting API keys: 'AIXPLAIN_API_KEY' and 'TEAM_API_KEY' are both provided but do not match. Please provide only one API key."
40
-
)
34
+
This function handles all API key validation logic:
35
+
1. Ensures at least one API key is provided
36
+
2. Prevents conflicting API keys
37
+
3. Auto-normalizes AIXPLAIN_API_KEY to TEAM_API_KEY if needed
38
+
39
+
Raises:
40
+
Exception: If no API keys are provided or if conflicting keys are detected
41
+
"""
42
+
globalTEAM_API_KEY, AIXPLAIN_API_KEY
43
+
44
+
ifnotTEAM_API_KEYandnotAIXPLAIN_API_KEY:
45
+
raiseException(
46
+
"Neither 'AIXPLAIN_API_KEY' nor 'TEAM_API_KEY' has been set. Please set either environment variable. For help, please refer to the documentation (https://github.com/aixplain/aixplain#api-key-setup)"
"Conflicting API keys: 'AIXPLAIN_API_KEY' and 'TEAM_API_KEY' are both provided but do not match. Please provide only one API key."
52
+
)
53
+
54
+
ifAIXPLAIN_API_KEYandnotTEAM_API_KEY:
55
+
TEAM_API_KEY=AIXPLAIN_API_KEY
56
+
57
+
58
+
defcheck_api_keys_available():
59
+
"""Runtime check to ensure API keys are available.
60
+
61
+
This is used by decorators and other runtime validation.
62
+
Uses the same validation logic as the module-level check.
63
+
64
+
Raises:
65
+
Exception: If no valid API keys are available
66
+
"""
67
+
ifnotTEAM_API_KEYandnotAIXPLAIN_API_KEY:
68
+
raiseException(
69
+
"An API key is required to run this operation. Please set either 'AIXPLAIN_API_KEY' or 'TEAM_API_KEY'. For help, please refer to the documentation (https://github.com/aixplain/aixplain#api-key-setup)"
70
+
)
41
71
42
72
43
-
ifAIXPLAIN_API_KEYandnotTEAM_API_KEY:
44
-
TEAM_API_KEY=AIXPLAIN_API_KEY
73
+
# Perform initial validation at module import time
"description": "## ROLE\nText Translator\n\n## GOAL\nTranslate the text supplied into the users desired language.\n\n## BACKSTORY\nYou are a text translation agent. You will be provided a text in the source language and expected to translate in the target language.",
24
+
"description": "Text Translator",
25
+
"instructions": "You are a text translation agent. You will be provided a text in the source language and expected to translate in the target language.",
22
26
"tasks": [
23
27
{
24
28
"name": "Text translation",
@@ -32,7 +36,8 @@
32
36
"agent_name": "Test Speech Synthesis agent",
33
37
"llm_id": "6646261c6eb563165658bbb1",
34
38
"llm_name": "GPT4o",
35
-
"description": "## ROLE\nSpeech Synthesizer\n\n## GOAL\nTranscribe the translated text into speech.\n\n## BACKSTORY\nYou are a speech synthesizing agent. You will be provided a text to synthesize into audio and return the audio link.",
39
+
"description": "Speech Synthesizer",
40
+
"instructions": "You are a speech synthesizing agent. You will be provided a text to synthesize into audio and return the audio link.",
36
41
"tasks": [
37
42
{
38
43
"name": "Speech synthesis",
@@ -48,6 +53,7 @@
48
53
49
54
50
55
defparse_tools(tools_info):
56
+
"""Parse tool information into AgentFactory model tools."""
0 commit comments