Skip to content

Commit

Permalink
chore: Add check for OPENAI_API_KEY environment variable before launc…
Browse files Browse the repository at this point in the history
…hing Startr.Team
  • Loading branch information
opencoca committed Jul 27, 2024
1 parent 6d6c3b8 commit 97821ad
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from chatdev.chat_chain import ChatChain


def get_config(company):
"""
return configuration json files for ChatChain
Expand Down Expand Up @@ -132,6 +131,28 @@ def get_config(company):
# Parse the arguments
args = parser.parse_args()

# Detect if API key is set in the environment and if not, print a warning and exit
if 'OPENAI_API_KEY' not in os.environ:
#Color print Blue
print("\033[94m \n")
print("""Warning: OPENAI_API_KEY environment variable is not set.
\033[0m
Please set the key before launching Startr.Team.
To set the API key, run the following command in your terminal:
export OPENAI_API_KEY="your-api-key-here"
To make the change permanent, add the command to your shell profile file (e.g. ~/.bashrc).
Or to you loacl .env file.
If you don't have an API key, you can get one at https://platform.openai.com/signup
\033[94m \n
TODO: Alternatively use GROQ API key.
\033[0m \n
""")
sys.exit(1)

# Start ChatDev

Expand Down

1 comment on commit 97821ad

@ChosenFewPet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omg y’all been busy much respect to to all I salute, guessing im rolling with the right team you thank you glad to be a part of the inner circle

Please sign in to comment.