rlancemartin commited on
Commit
118cf75
1 Parent(s): 166b383

Add check for API keys

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -335,12 +335,12 @@ def run_evaluation(chain, retriever, eval_set, grade_prompt, retriever_type, num
335
  # Auth
336
  st.sidebar.image("img/diagnostic.jpg")
337
 
338
- with st.sidebar.form("user_input"):
 
 
 
339
 
340
- oai_api_key = st.sidebar.text_input("`OpenAI API Key:`", type="password")
341
- os.environ["OPENAI_API_KEY"] = oai_api_key
342
- ant_api_key = st.sidebar.text_input("`(Optional) Anthropic API Key:`", type="password")
343
- os.environ["ANTHROPIC_API_KEY"] = ant_api_key
344
 
345
  num_eval_questions = st.select_slider("`Number of eval questions`",
346
  options=[1, 5, 10, 15, 20], value=5)
@@ -407,7 +407,7 @@ with st.form(key='file_inputs'):
407
 
408
  submitted = st.form_submit_button("Submit files")
409
 
410
- if uploaded_file:
411
 
412
  # Load docs
413
  text = load_docs(uploaded_file)
@@ -481,3 +481,7 @@ if uploaded_file:
481
  color='expt number',
482
  tooltip=['expt number', 'Retrieval score', 'Latency', 'Answer score'])
483
  st.altair_chart(c, use_container_width=True, theme="streamlit")
 
 
 
 
 
335
  # Auth
336
  st.sidebar.image("img/diagnostic.jpg")
337
 
338
+ oai_api_key = st.sidebar.text_input("`OpenAI API Key:`", type="password")
339
+ ant_api_key = st.sidebar.text_input("`(Optional) Anthropic API Key:`", type="password")
340
+ os.environ["OPENAI_API_KEY"] = oai_api_key
341
+ os.environ["ANTHROPIC_API_KEY"] = ant_api_key
342
 
343
+ with st.sidebar.form("user_input"):
 
 
 
344
 
345
  num_eval_questions = st.select_slider("`Number of eval questions`",
346
  options=[1, 5, 10, 15, 20], value=5)
 
407
 
408
  submitted = st.form_submit_button("Submit files")
409
 
410
+ if uploaded_file and oai_api_key:
411
 
412
  # Load docs
413
  text = load_docs(uploaded_file)
 
481
  color='expt number',
482
  tooltip=['expt number', 'Retrieval score', 'Latency', 'Answer score'])
483
  st.altair_chart(c, use_container_width=True, theme="streamlit")
484
+
485
+ else:
486
+
487
+ st.warning("Please input file and API key(s)!")