Zekun Wu commited on
Commit
cbbb1a3
1 Parent(s): d192165
Files changed (2) hide show
  1. app.py +22 -21
  2. prompt_test.csv +5 -0
app.py CHANGED
@@ -35,32 +35,33 @@ if st.sidebar.button("Reset Model Info"):
35
  if st.sidebar.button("Submit Model Info"):
36
  st.session_state.model_submitted = True
37
 
38
- # Ensure experiment settings are only shown if model info is submitted
39
- if st.session_state.model_submitted:
40
- parameters = {"temperature": st.session_state.temperature, "max_tokens": st.session_state.max_tokens}
41
-
42
- st.session_state.group_name = st.text_input("Group Name", value=st.session_state.group_name)
43
- st.session_state.privilege_label = st.text_input("Privilege Name", value=st.session_state.privilege_label)
44
- st.session_state.protect_label = st.text_input("Protect Name", value=st.session_state.protect_label)
45
- st.session_state.num_run = st.number_input("Number of runs", min_value=1, value=st.session_state.num_run)
46
  st.session_state.uploaded_file = st.file_uploader("Choose a file")
47
-
48
- if st.session_state.uploaded_file is not None and not st.session_state.data_processed:
49
  data = StringIO(st.session_state.uploaded_file.getvalue().decode("utf-8"))
50
  df = pd.read_csv(data)
51
 
52
- if st.button('Process Data'):
53
- # Initialize the correct agent based on model type
54
- if model_type == 'AzureAgent':
55
- agent = AzureAgent(st.session_state.api_key, st.session_state.endpoint_url, st.session_state.deployment_name)
56
- else:
57
- agent = GPTAgent(st.session_state.api_key, st.session_state.endpoint_url, st.session_state.deployment_name, api_version)
 
 
58
 
59
- # Process data and display results
60
- with st.spinner('Processing data...'):
61
- df = process_scores(df, st.session_state.num_run, parameters, st.session_state.privilege_label, st.session_state.protect_label, agent, st.session_state.group_name)
62
- st.session_state.data_processed = True # Mark as processed
63
- st.write('Processed Data:', df)
 
64
 
65
  if st.button("Reset Experiment Settings"):
66
  st.session_state.group_name = ""
 
35
  if st.sidebar.button("Submit Model Info"):
36
  st.session_state.model_submitted = True
37
 
38
+ # File selection
39
+ file_options = st.radio("Choose file source:", ["Upload", "Example"])
40
+ if file_options == "Example":
41
+ example_data = """Put your CSV data here as a multi-line string or load from a file path."""
42
+ data = StringIO(example_data)
43
+ df = pd.read_csv(data)
44
+ else:
 
45
  st.session_state.uploaded_file = st.file_uploader("Choose a file")
46
+ if st.session_state.uploaded_file is not None:
 
47
  data = StringIO(st.session_state.uploaded_file.getvalue().decode("utf-8"))
48
  df = pd.read_csv(data)
49
 
50
+ # Ensure experiment settings are only shown if model info is submitted
51
+ if st.session_state.model_submitted and df is not None:
52
+ if st.button('Process Data'):
53
+ # Initialize the correct agent based on model type
54
+ if model_type == 'AzureAgent':
55
+ agent = AzureAgent(st.session_state.api_key, st.session_state.endpoint_url, st.session_state.deployment_name)
56
+ else:
57
+ agent = GPTAgent(st.session_state.api_key, st.session_state.endpoint_url, st.session_state.deployment_name, api_version)
58
 
59
+ # Process data and display results
60
+ with st.spinner('Processing data...'):
61
+ parameters = {"temperature": st.session_state.temperature, "max_tokens": st.session_state.max_tokens}
62
+ df = process_scores(df, st.session_state.num_run, parameters, st.session_state.privilege_label, st.session_state.protect_label, agent, st.session_state.group_name)
63
+ st.session_state.data_processed = True # Mark as processed
64
+ st.write('Processed Data:', df)
65
 
66
  if st.button("Reset Experiment Settings"):
67
  st.session_state.group_name = ""
prompt_test.csv ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Age,MainBranch,Gender,EdLevel,YearsCode,YearsCodePro,Country,MentalHealth,Employment,HaveWorkedWith,PreviousSalary,ComputerSkills
2
+ >35,Yes,Female,Undergraduate,6.0,5.0,Israel,No,1,JavaScript;Ruby;Homebrew;Yarn;React.js;Ruby on Rails;DigitalOcean;Heroku;PostgreSQL;Redis,138288.0,10
3
+ >35,Yes,Female,Undergraduate,19.0,19.0,Ecuador,Yes,1,C#;SQL;ASP.NET;Microsoft SQL Server,30000.0,4
4
+ <35,Yes,Female,Undergraduate,7.0,4.0,United Kingdom of Great Britain and Northern Ireland,No,1,Bash/Shell;Groovy;Java;Kotlin;Docker;Git;Kubernetes;Terraform;Spring;AWS;DynamoDB;PostgreSQL,93067.0,12
5
+ >35,Yes,Female,Other,13.0,11.0,United States of America,Yes,1,C#;HTML/CSS;JavaScript;SQL;TypeScript;Docker;Git;Kubernetes;Angular;ASP.NET;ASP.NET Core ;Google Cloud Platform;Microsoft Azure;Elasticsearch;Microsoft SQL Server;SQLite,132500.0,16