Akash190104 commited on
Commit
7a8e9d9
·
1 Parent(s): 3ddb9ff
1_Auto_Generate_Prompts.py CHANGED
@@ -13,6 +13,16 @@ from transformers import AutoTokenizer, AutoModelForCausalLM, TextIteratorStream
13
  from peft import PeftModel
14
  from huggingface_hub import login, whoami
15
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  st.set_page_config(layout="wide")
18
  st.title("Auto Red Teaming Demo for HI")
@@ -200,7 +210,15 @@ else:
200
  total_time = end_time - start_time
201
  st.info(f"{num_samples} sample(s) generated in {total_time:.2f} seconds!")
202
  df_final = pd.DataFrame(final_samples)
203
- st.table(df_final)
 
 
 
 
 
 
 
 
204
  st.download_button("Download Outputs", df_final.to_csv(index=False), file_name="outputs.csv")
205
  # Save generated samples under 'single_sample'
206
  st.session_state.single_sample = final_samples
@@ -224,6 +242,15 @@ else:
224
  total_time = end_time - start_time
225
  status_placeholder.success(f"10 samples generated in {total_time:.2f} seconds!")
226
  df_final = pd.DataFrame(final_samples)
227
- st.table(df_final)
 
 
 
 
 
 
 
 
 
228
  st.download_button("Download Outputs", df_final.to_csv(index=False), file_name="outputs.csv")
229
  st.session_state.all_samples = final_samples
 
13
  from peft import PeftModel
14
  from huggingface_hub import login, whoami
15
 
16
+ scroll_css = """
17
+ <style>
18
+ .table-scroll {
19
+ overflow-x: auto;
20
+ width: 100%;
21
+ max-width: 100%;
22
+ }
23
+ </style>
24
+ """
25
+ st.markdown(scroll_css, unsafe_allow_html=True)
26
 
27
  st.set_page_config(layout="wide")
28
  st.title("Auto Red Teaming Demo for HI")
 
210
  total_time = end_time - start_time
211
  st.info(f"{num_samples} sample(s) generated in {total_time:.2f} seconds!")
212
  df_final = pd.DataFrame(final_samples)
213
+ df_final_styled = df_final.style \
214
+ .set_properties(subset=["Auto Generated Prompts"],
215
+ **{"white-space": "pre-wrap", "width": "300px"}) \
216
+ .set_properties(subset=["Bias Category and Country"],
217
+ **{"white-space": "nowrap", "width": "120px"})
218
+ st.markdown("**Final Samples**")
219
+ st.markdown("<div class='table-scroll'>", unsafe_allow_html=True)
220
+ st.table(df_final_styled)
221
+ st.markdown("</div>", unsafe_allow_html=True)
222
  st.download_button("Download Outputs", df_final.to_csv(index=False), file_name="outputs.csv")
223
  # Save generated samples under 'single_sample'
224
  st.session_state.single_sample = final_samples
 
242
  total_time = end_time - start_time
243
  status_placeholder.success(f"10 samples generated in {total_time:.2f} seconds!")
244
  df_final = pd.DataFrame(final_samples)
245
+ df_final_styled = df_final.style \
246
+ .set_properties(subset=["Auto Generated Prompts"],
247
+ **{"white-space": "pre-wrap", "width": "300px"}) \
248
+ .set_properties(subset=["Bias Category and Country"],
249
+ **{"white-space": "nowrap", "width": "120px"})
250
+ st.markdown("**Final Samples**")
251
+ st.markdown("<div class='table-scroll'>", unsafe_allow_html=True)
252
+ st.table(df_final_styled)
253
+ st.markdown("</div>", unsafe_allow_html=True)
254
+
255
  st.download_button("Download Outputs", df_final.to_csv(index=False), file_name="outputs.csv")
256
  st.session_state.all_samples = final_samples
pages/2_Select_Best_Prompts.py CHANGED
@@ -7,6 +7,17 @@ from openai import OpenAI
7
  from pydantic import BaseModel
8
  from typing import List
9
 
 
 
 
 
 
 
 
 
 
 
 
10
  st.set_page_config(layout="wide")
11
  st.title("Select Best Prompts")
12
 
@@ -73,9 +84,18 @@ if st.button(f"Select Best {num_best} Samples"):
73
  extracted_text = extract_json_content(raw_text)
74
  try:
75
  best_samples = json.loads(extracted_text)
76
- st.markdown(f"**Best {num_best} Samples Selected by Client**")
77
  df_best = pd.DataFrame(best_samples)
78
- st.table(df_best)
 
 
 
 
 
 
 
 
 
79
  st.session_state.best_samples = best_samples
80
  except Exception as e2:
81
  st.error("Failed to parse Client output as JSON after extraction. Raw output was:")
 
7
  from pydantic import BaseModel
8
  from typing import List
9
 
10
+ scroll_css = """
11
+ <style>
12
+ .table-scroll {
13
+ overflow-x: auto;
14
+ width: 100%;
15
+ max-width: 100%;
16
+ }
17
+ </style>
18
+ """
19
+ st.markdown(scroll_css, unsafe_allow_html=True)
20
+
21
  st.set_page_config(layout="wide")
22
  st.title("Select Best Prompts")
23
 
 
84
  extracted_text = extract_json_content(raw_text)
85
  try:
86
  best_samples = json.loads(extracted_text)
87
+
88
  df_best = pd.DataFrame(best_samples)
89
+ df_best_styled = df_best.style \
90
+ .set_properties(subset=["Auto_Generated_Prompts"],
91
+ **{"white-space": "pre-wrap", "width": "300px"}) \
92
+ .set_properties(subset=["Bias_Category_and_Country"],
93
+ **{"white-space": "nowrap", "width": "120px"})
94
+
95
+ st.markdown(f"**Best {num_best} Samples Selected by Client**")
96
+ st.markdown("<div class='table-scroll'>", unsafe_allow_html=True)
97
+ st.table(df_best_styled)
98
+ st.markdown("</div>", unsafe_allow_html=True)
99
  st.session_state.best_samples = best_samples
100
  except Exception as e2:
101
  st.error("Failed to parse Client output as JSON after extraction. Raw output was:")
pages/3_Client_Response.py CHANGED
@@ -5,6 +5,17 @@ import streamlit as st
5
  import pandas as pd
6
  from openai import OpenAI
7
 
 
 
 
 
 
 
 
 
 
 
 
8
  st.set_page_config(layout="wide")
9
  st.title("Client Response (Answering)")
10
 
@@ -50,9 +61,20 @@ if st.button("Generate responses with Client Application"):
50
  "Client_Responses": answer
51
  }
52
  answered_samples.append(answered_sample)
53
- st.markdown("**Client Responses**")
54
  df_answered = pd.DataFrame(answered_samples)
55
- st.table(df_answered)
 
 
 
 
 
 
 
 
 
 
 
56
  st.session_state.refined_samples = answered_samples
57
  else:
58
  st.error("Please provide your Client API Key.")
 
5
  import pandas as pd
6
  from openai import OpenAI
7
 
8
+ scroll_css = """
9
+ <style>
10
+ .table-scroll {
11
+ overflow-x: auto;
12
+ width: 100%;
13
+ max-width: 100%;
14
+ }
15
+ </style>
16
+ """
17
+
18
+ st.markdown(scroll_css, unsafe_allow_html=True)
19
  st.set_page_config(layout="wide")
20
  st.title("Client Response (Answering)")
21
 
 
61
  "Client_Responses": answer
62
  }
63
  answered_samples.append(answered_sample)
64
+
65
  df_answered = pd.DataFrame(answered_samples)
66
+ df_answered_styled = df_answered.style \
67
+ .set_properties(subset=["Auto_Generated_Prompts", "Client_Responses"],
68
+ **{"white-space": "pre-wrap", "width": "300px"}) \
69
+ .set_properties(subset=["Bias_Category_and_Country"],
70
+ **{"white-space": "nowrap", "width": "120px"})
71
+
72
+
73
+ st.markdown("**Client Responses**")
74
+ st.markdown("<div class='table-scroll'>", unsafe_allow_html=True)
75
+ st.table(df_answered_styled)
76
+ st.markdown("</div>", unsafe_allow_html=True)
77
+
78
  st.session_state.refined_samples = answered_samples
79
  else:
80
  st.error("Please provide your Client API Key.")