Spaces:
Build error
Build error
Zekun Wu commited on
Commit ·
382ddb8
1
Parent(s): fd767e5
update
Browse files
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 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
| 110 |
|
| 111 |
|
| 112 |
-
def to_excel(df):
|
| 113 |
-
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
|
| 128 |
-
if st.button("Generate Potshots"):
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
| 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')
|