tushar310 commited on
Commit
19afc02
·
1 Parent(s): 9a0858c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -14,12 +14,12 @@ for message in st.session_state.messages:
14
  with st.chat_message(message["role"]):
15
  st.markdown(message["content"])
16
 
17
- openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
18
 
19
- if "openai_api_key" not in st.session_state:
20
- st.session_state["openai_api_key"] = openai_api_key
21
 
22
- if not openai_api_key:
23
  st.info("Please add your OpenAI API key to continue.")
24
  st.stop()
25
 
@@ -37,7 +37,7 @@ if prompt := st.chat_input("What is up?"):
37
  {"role": m["role"], "content": m["content"]}
38
  for m in st.session_state.messages
39
  ],
40
- openai_api_key = openai_api_key,
41
  max_tokens=8000,
42
  stream=True,
43
  ):
 
14
  with st.chat_message(message["role"]):
15
  st.markdown(message["content"])
16
 
17
+ openai.api_key = st.sidebar.text_input("OpenAI API Key", type="password")
18
 
19
+ if "openai.api_key" not in st.session_state:
20
+ st.session_state["openai.api_key"] = openai.api_key
21
 
22
+ if not openai.api_key:
23
  st.info("Please add your OpenAI API key to continue.")
24
  st.stop()
25
 
 
37
  {"role": m["role"], "content": m["content"]}
38
  for m in st.session_state.messages
39
  ],
40
+ openai_api_key = openai.api_key,
41
  max_tokens=8000,
42
  stream=True,
43
  ):