Skip to content

Commit 97821ad

Browse files
committed
chore: Add check for OPENAI_API_KEY environment variable before launching Startr.Team
1 parent 6d6c3b8 commit 97821ad

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

run.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
from chatdev.chat_chain import ChatChain
2525

26-
2726
def get_config(company):
2827
"""
2928
return configuration json files for ChatChain
@@ -132,6 +131,28 @@ def get_config(company):
132131
# Parse the arguments
133132
args = parser.parse_args()
134133

134+
# Detect if API key is set in the environment and if not, print a warning and exit
135+
if 'OPENAI_API_KEY' not in os.environ:
136+
#Color print Blue
137+
print("\033[94m \n")
138+
print("""Warning: OPENAI_API_KEY environment variable is not set.
139+
\033[0m
140+
Please set the key before launching Startr.Team.
141+
142+
To set the API key, run the following command in your terminal:
143+
144+
export OPENAI_API_KEY="your-api-key-here"
145+
146+
To make the change permanent, add the command to your shell profile file (e.g. ~/.bashrc).
147+
Or to you loacl .env file.
148+
149+
If you don't have an API key, you can get one at https://platform.openai.com/signup
150+
151+
\033[94m \n
152+
TODO: Alternatively use GROQ API key.
153+
\033[0m \n
154+
""")
155+
sys.exit(1)
135156

136157
# Start ChatDev
137158

0 commit comments

Comments
 (0)