Zekun Wu commited on
Commit
382ddb8
·
1 Parent(s): fd767e5
Files changed (1) hide show
  1. app.py +48 -37
app.py CHANGED
@@ -49,6 +49,15 @@ class GPTAgent:
49
 
50
 
51
 
 
 
 
 
 
 
 
 
 
52
 
53
  def generate_potshot_prompt(batch, role, tone, audience, values):
54
  prompt = f"""You are a recruitment specialist tasked with generating witty and engaging recruitment potshots.
@@ -99,53 +108,55 @@ def get_potshots(n_repeat=1, batch=20, role="Developer", tone="humorous", audien
99
  # Streamlit App Interface
100
  st.title("Recruiting Potshots Generator")
101
 
102
- # Input Fields for Customization
103
- # Input Fields for Full Customization with Default Values
104
- role = st.text_input("Job Role", value="Developer", help="Enter the job role you are recruiting for. Default is 'Developer'.")
105
- tone = st.text_input("Tone of the Potshots", value="humorous", help="Enter any tone for the potshots (e.g., humorous, serious, edgy). Default is 'humorous'.")
106
- audience = st.text_input("Target Audience", value="tech-savvy candidates", help="Define the target audience for the potshots. Default is 'tech-savvy candidates'.")
107
- values = st.text_area("Company Values", value="innovation, teamwork, transparency", help="Enter your company values that should be reflected in the potshots. Default is 'innovation, teamwork, transparency'.")
108
- batch_size = st.number_input("Batch Size", min_value=1, max_value=100, value=10)
109
- repeat_times = st.number_input("Number of Batches", min_value=1, max_value=10, value=1)
 
 
110
 
111
 
112
- def to_excel(df):
113
- output = BytesIO()
114
 
115
- # Use the 'with' statement to handle the file writer and ensure proper closure
116
- with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
117
- df.to_excel(writer, index=False, sheet_name='Potshots')
118
 
119
- # Get the processed data from the buffer
120
- processed_data = output.getvalue()
121
 
122
- # Reset the buffer for safety (useful if this is reused)
123
- output.seek(0)
124
 
125
- return processed_data
126
 
127
 
128
- if st.button("Generate Potshots"):
129
- with st.spinner("Generating customized potshots..."):
130
- df = get_potshots(n_repeat=repeat_times, batch=batch_size, role=role, tone=tone, audience=audience,
131
- values=values)
132
 
133
- # Display the generated potshots as a table
134
- st.write("### Generated Potshots")
135
- st.dataframe(df)
136
 
137
- excel_data = to_excel(df)
138
- file_name = "potshots.xlsx"
139
 
140
- # Open and read the file to serve for download
141
- with open(file_name, "wb") as f:
142
- f.write(excel_data)
143
 
144
- # Provide a download button for the Excel file
145
- with open(file_name, "rb") as template_file:
146
- template_byte = template_file.read()
147
 
148
- st.download_button(label="Click to Download Potshots File",
149
- data=template_byte,
150
- file_name="potshots.xlsx",
151
- mime='application/octet-stream')
 
49
 
50
 
51
 
52
+ def authenticate_user():
53
+ user_key = st.text_input("Enter your authentication key", type="password")
54
+
55
+ if user_key == os.getenv("AUTH_KEY"):
56
+ st.success("Authentication successful!")
57
+ return True
58
+ else:
59
+ st.error("Invalid authentication key. Please try again.")
60
+ return False
61
 
62
  def generate_potshot_prompt(batch, role, tone, audience, values):
63
  prompt = f"""You are a recruitment specialist tasked with generating witty and engaging recruitment potshots.
 
108
  # Streamlit App Interface
109
  st.title("Recruiting Potshots Generator")
110
 
111
+ if authenticate_user():
112
+
113
+ # Input Fields for Customization
114
+ # Input Fields for Full Customization with Default Values
115
+ role = st.text_input("Job Role", value="Developer", help="Enter the job role you are recruiting for. Default is 'Developer'.")
116
+ tone = st.text_input("Tone of the Potshots", value="humorous", help="Enter any tone for the potshots (e.g., humorous, serious, edgy). Default is 'humorous'.")
117
+ audience = st.text_input("Target Audience", value="tech-savvy candidates", help="Define the target audience for the potshots. Default is 'tech-savvy candidates'.")
118
+ values = st.text_area("Company Values", value="innovation, teamwork, transparency", help="Enter your company values that should be reflected in the potshots. Default is 'innovation, teamwork, transparency'.")
119
+ batch_size = st.number_input("Batch Size", min_value=1, max_value=100, value=10)
120
+ repeat_times = st.number_input("Number of Batches", min_value=1, max_value=10, value=1)
121
 
122
 
123
+ def to_excel(df):
124
+ output = BytesIO()
125
 
126
+ # Use the 'with' statement to handle the file writer and ensure proper closure
127
+ with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
128
+ df.to_excel(writer, index=False, sheet_name='Potshots')
129
 
130
+ # Get the processed data from the buffer
131
+ processed_data = output.getvalue()
132
 
133
+ # Reset the buffer for safety (useful if this is reused)
134
+ output.seek(0)
135
 
136
+ return processed_data
137
 
138
 
139
+ if st.button("Generate Potshots"):
140
+ with st.spinner("Generating customized potshots..."):
141
+ df = get_potshots(n_repeat=repeat_times, batch=batch_size, role=role, tone=tone, audience=audience,
142
+ values=values)
143
 
144
+ # Display the generated potshots as a table
145
+ st.write("### Generated Potshots")
146
+ st.dataframe(df)
147
 
148
+ excel_data = to_excel(df)
149
+ file_name = "potshots.xlsx"
150
 
151
+ # Open and read the file to serve for download
152
+ with open(file_name, "wb") as f:
153
+ f.write(excel_data)
154
 
155
+ # Provide a download button for the Excel file
156
+ with open(file_name, "rb") as template_file:
157
+ template_byte = template_file.read()
158
 
159
+ st.download_button(label="Click to Download Potshots File",
160
+ data=template_byte,
161
+ file_name="potshots.xlsx",
162
+ mime='application/octet-stream')