Nyanfa commited on
Commit
95f42b1
·
verified ·
1 Parent(s): 970ed2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -9,9 +9,13 @@ st.title("Cohere Chat UI")
9
  if "api_key" not in st.session_state:
10
  api_key = st.text_input("Enter your API Key", type="password")
11
  if api_key:
12
- st.session_state.api_key = api_key
13
- client = cohere.Client(api_key=api_key)
14
- st.rerun()
 
 
 
 
15
  else:
16
  st.warning("Please enter your API key to use the app. You can obtain your API key from here: https://dashboard.cohere.com/api-keys")
17
  st.stop()
@@ -179,7 +183,7 @@ with st.sidebar:
179
  st.header("Change API Key")
180
  new_api_key = st.text_input("Enter new API Key", type="password")
181
  if st.button("Update API Key"):
182
- if new_api_key:
183
  st.session_state.api_key = new_api_key
184
  client = cohere.Client(api_key=new_api_key)
185
  st.success("API Key updated successfully!")
 
9
  if "api_key" not in st.session_state:
10
  api_key = st.text_input("Enter your API Key", type="password")
11
  if api_key:
12
+ if isascii(api_key):
13
+ st.session_state.api_key = api_key
14
+ client = cohere.Client(api_key=api_key)
15
+ st.rerun()
16
+ else:
17
+ st.warning("Please enter your API key correctly.")
18
+ st.stop()
19
  else:
20
  st.warning("Please enter your API key to use the app. You can obtain your API key from here: https://dashboard.cohere.com/api-keys")
21
  st.stop()
 
183
  st.header("Change API Key")
184
  new_api_key = st.text_input("Enter new API Key", type="password")
185
  if st.button("Update API Key"):
186
+ if new_api_key and isascii(new_api_key):
187
  st.session_state.api_key = new_api_key
188
  client = cohere.Client(api_key=new_api_key)
189
  st.success("API Key updated successfully!")