lingyit1108 commited on
Commit
a561bc6
β€’
1 Parent(s): 4de5f47

added compatible secrets management code

Browse files
Files changed (1) hide show
  1. streamlit_app.py +6 -1
streamlit_app.py CHANGED
@@ -6,12 +6,15 @@ from openai import OpenAI
6
 
7
  # App title
8
  st.set_page_config(page_title="πŸ’¬ Open AI Chatbot")
 
9
 
10
  # Replicate Credentials
11
  with st.sidebar:
12
  st.title("πŸ’¬ Open AI Chatbot")
13
  st.write("This chatbot is created using the GPT model from Open AI.")
14
- if "OPENAI_API_KEY" in st.secrets:
 
 
15
  st.success("API key already provided!", icon="βœ…")
16
  openai_api = st.secrets["OPENAI_API_KEY"]
17
  else:
@@ -20,6 +23,8 @@ with st.sidebar:
20
  st.warning("Please enter your credentials!", icon="⚠️")
21
  else:
22
  st.success("Proceed to entering your prompt message!", icon="πŸ‘‰")
 
 
23
  os.environ["OPENAI_API_KEY"] = openai_api
24
 
25
  st.subheader("Models and parameters")
 
6
 
7
  # App title
8
  st.set_page_config(page_title="πŸ’¬ Open AI Chatbot")
9
+ openai_api = os.getenv("OPENAI_API_KEY")
10
 
11
  # Replicate Credentials
12
  with st.sidebar:
13
  st.title("πŸ’¬ Open AI Chatbot")
14
  st.write("This chatbot is created using the GPT model from Open AI.")
15
+ if openai_api:
16
+ pass
17
+ elif "OPENAI_API_KEY" in st.secrets:
18
  st.success("API key already provided!", icon="βœ…")
19
  openai_api = st.secrets["OPENAI_API_KEY"]
20
  else:
 
23
  st.warning("Please enter your credentials!", icon="⚠️")
24
  else:
25
  st.success("Proceed to entering your prompt message!", icon="πŸ‘‰")
26
+
27
+ ### for streamlit purpose
28
  os.environ["OPENAI_API_KEY"] = openai_api
29
 
30
  st.subheader("Models and parameters")