Zekun Wu commited on
Commit
b0eb8db
·
1 Parent(s): 5485067
Files changed (1) hide show
  1. pages/2_batch_evaluation.py +20 -2
pages/2_batch_evaluation.py CHANGED
@@ -1,9 +1,10 @@
 
1
  import pandas as pd
2
  import streamlit as st
3
  from util.evaluator import evaluator, write_evaluation_commentary
4
- import os
5
 
6
 
 
7
  def check_password():
8
  def password_entered():
9
  if password_input == os.getenv('PASSWORD'):
@@ -18,7 +19,7 @@ def check_password():
18
  st.error("Please enter a valid password to access the demo.")
19
 
20
 
21
-
22
  def batch_evaluate(uploaded_file):
23
  df = pd.read_csv(uploaded_file)
24
  eval_instance = evaluator('gpt4-1106') # Assuming fixed model name for simplicity
@@ -45,12 +46,29 @@ def batch_evaluate(uploaded_file):
45
  return pd.DataFrame(results)
46
 
47
 
 
48
  st.title('Natural Language Explanation Demo')
49
 
 
50
  if not st.session_state.get('password_correct', False):
51
  check_password()
52
  else:
53
  st.sidebar.success("Password Verified. Proceed with the demo.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  uploaded_file = st.file_uploader("Upload CSV file with 'question' and 'explanation' columns", type=['csv'])
55
 
56
  if uploaded_file is not None:
 
1
+ import os
2
  import pandas as pd
3
  import streamlit as st
4
  from util.evaluator import evaluator, write_evaluation_commentary
 
5
 
6
 
7
+ # Function to check password
8
  def check_password():
9
  def password_entered():
10
  if password_input == os.getenv('PASSWORD'):
 
19
  st.error("Please enter a valid password to access the demo.")
20
 
21
 
22
+ # Function to batch evaluate explanations
23
  def batch_evaluate(uploaded_file):
24
  df = pd.read_csv(uploaded_file)
25
  eval_instance = evaluator('gpt4-1106') # Assuming fixed model name for simplicity
 
46
  return pd.DataFrame(results)
47
 
48
 
49
+ # Title of the application
50
  st.title('Natural Language Explanation Demo')
51
 
52
+ # Check if password has been validated
53
  if not st.session_state.get('password_correct', False):
54
  check_password()
55
  else:
56
  st.sidebar.success("Password Verified. Proceed with the demo.")
57
+
58
+ st.write("""
59
+ ### Instructions for Uploading CSV
60
+ Please upload a CSV file with the following columns:
61
+ - `question`: The question you want evaluated.
62
+ - `explanation`: The explanation corresponding to the question.
63
+
64
+ **Example CSV Format:**
65
+ ```
66
+ question,explanation
67
+ "What causes rainbows to appear in the sky?","Rainbows appear when sunlight is refracted, dispersed, and reflected inside water droplets in the atmosphere, resulting in a spectrum of light appearing in the sky."
68
+ "Why is the sky blue?","The sky is blue because molecules in the air scatter blue light from the sun more than they scatter red light."
69
+ ```
70
+ """)
71
+
72
  uploaded_file = st.file_uploader("Upload CSV file with 'question' and 'explanation' columns", type=['csv'])
73
 
74
  if uploaded_file is not None: