Skip to content

Commit

Permalink
feat: display warning if no api key is provided, closes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoleg committed Apr 10, 2024
1 parent 79aa508 commit ed6f971
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ def display_sidebar():
)


def check_api_key_availability():
"""Checks whether the OPENAI_API_KEY environment variable is set and displays warning if not."""
if not OPENAI_API_KEY:
display_warning_message(
"It seems you haven't provided an API-Key. Make sure to do so according to the instructions: https://github.com/sudoleg/ytai?tab=readme-ov-file#installation--usage"
)


def main():
st.set_page_config(
page_title="YouTube AI", layout="wide", initial_sidebar_state="auto"
Expand All @@ -107,7 +115,9 @@ def main():
st.session_state.temperature = get_default_config_value("temperature")
if "save_responses" not in st.session_state:
st.session_state.save_responses = False

display_sidebar()
check_api_key_availability()

# define the columns
col1, col2 = st.columns([0.4, 0.6], gap="large")
Expand Down

0 comments on commit ed6f971

Please sign in to comment.