Spaces:
Sleeping
Sleeping
Update to Spinner
Browse files
app.py
CHANGED
@@ -231,43 +231,58 @@ with st.container():
|
|
231 |
system = sys_prompt.format(job=st.session_state["pdf_data_jobdescription_string"], resume=st.session_state["pdf_data_cvs_string"], n=15)
|
232 |
if not st.session_state["ai_questions"]:
|
233 |
try:
|
234 |
-
st.write("The questions are generated. This may take a short moment...")
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
st.session_state["
|
248 |
-
|
|
|
|
|
249 |
except Exception as e:
|
250 |
print(f"Fehler beim generieren der Fragen: {str(e)}")
|
251 |
st.error("An error has occurred. Please reload the page or contact the admin.", icon="🚨")
|
252 |
else:
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
st.session_state["
|
264 |
-
st.
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
for i,final_q in enumerate(st.session_state["final_question_string"]):
|
272 |
cols_final = st.columns([5,1])
|
273 |
with cols_final[1]:
|
@@ -336,4 +351,8 @@ with st.container():
|
|
336 |
|
337 |
|
338 |
if not upload_success:
|
339 |
-
st.error('An error has occurred. Please contact the administrator. Sorry for the inconvenience.', icon="🚨")
|
|
|
|
|
|
|
|
|
|
231 |
system = sys_prompt.format(job=st.session_state["pdf_data_jobdescription_string"], resume=st.session_state["pdf_data_cvs_string"], n=15)
|
232 |
if not st.session_state["ai_questions"]:
|
233 |
try:
|
234 |
+
# st.write("The questions are generated. This may take a short moment...")
|
235 |
+
st.info("The questions are generated. This may take a short moment.", icon="ℹ️")
|
236 |
+
with st.spinner("Loading..."):
|
237 |
+
res = openai.ChatCompletion.create(
|
238 |
+
engine="gpt-4",
|
239 |
+
temperature=0.2,
|
240 |
+
messages=[
|
241 |
+
{
|
242 |
+
"role": "system",
|
243 |
+
"content": system,
|
244 |
+
},
|
245 |
+
],
|
246 |
+
)
|
247 |
+
st.session_state["ai_questions"] = [item for item in res.choices[0]["message"]["content"].split("\n") if len(item) > 0]
|
248 |
+
for i,q in enumerate(res.choices[0]["message"]["content"].split("\n")):
|
249 |
+
st.session_state["disable_row_"+str(i)] = False
|
250 |
+
st.rerun()
|
251 |
except Exception as e:
|
252 |
print(f"Fehler beim generieren der Fragen: {str(e)}")
|
253 |
st.error("An error has occurred. Please reload the page or contact the admin.", icon="🚨")
|
254 |
else:
|
255 |
+
if len(st.session_state["final_question_string"]) <= 0:
|
256 |
+
for i,question in enumerate(st.session_state["ai_questions"]):
|
257 |
+
cols = st.columns([5,1])
|
258 |
+
with cols[1]:
|
259 |
+
# if st.button("Accept",use_container_width=True,key="btn_accept_row_"+str(i)):
|
260 |
+
# print("accept")
|
261 |
+
# pattern = re.compile(r"^[1-9][0-9]?\.")
|
262 |
+
# questions_length = len(st.session_state["final_question_string"])
|
263 |
+
# question_from_text_area = st.session_state["text_area_"+str(i)]
|
264 |
+
# question_to_append = str(questions_length+1)+"."+re.sub(pattern, "", question_from_text_area)
|
265 |
+
# st.session_state["final_question_string"].append(question_to_append)
|
266 |
+
# st.session_state["disable_row_"+str(i)] = True
|
267 |
+
# st.rerun()
|
268 |
+
if st.button("Delete",use_container_width=True,key="btn_del_row_"+str(i)):
|
269 |
+
print("delete")
|
270 |
+
st.session_state["ai_questions"].remove(question)
|
271 |
+
st.rerun()
|
272 |
+
with cols[0]:
|
273 |
+
st.text_area(label="Question "+str(i+1)+":",value=question,label_visibility="collapsed",key="text_area_"+str(i),disabled=st.session_state["disable_row_"+str(i)])
|
274 |
+
st.write("If you are satisfied with the questions, then accept them. You can still sort them afterwards.")
|
275 |
+
if st.button("Accept all questions",use_container_width=True,key="accept_all_questions"):
|
276 |
+
print("accept all")
|
277 |
+
for i,question in enumerate(st.session_state["ai_questions"]):
|
278 |
+
print("accept")
|
279 |
+
pattern = re.compile(r"^[1-9][0-9]?\.")
|
280 |
+
questions_length = len(st.session_state["final_question_string"])
|
281 |
+
question_from_text_area = st.session_state["text_area_"+str(i)]
|
282 |
+
question_to_append = str(questions_length+1)+"."+re.sub(pattern, "", question_from_text_area)
|
283 |
+
st.session_state["final_question_string"].append(question_to_append)
|
284 |
+
st.session_state["disable_row_"+str(i)] = True
|
285 |
+
st.rerun()
|
286 |
for i,final_q in enumerate(st.session_state["final_question_string"]):
|
287 |
cols_final = st.columns([5,1])
|
288 |
with cols_final[1]:
|
|
|
351 |
|
352 |
|
353 |
if not upload_success:
|
354 |
+
st.error('An error has occurred. Please contact the administrator. Sorry for the inconvenience.', icon="🚨")
|
355 |
+
# else:
|
356 |
+
# col_submit_btn, col_empty, col_clear_btn = st.columns([1,4, 1])
|
357 |
+
# if col_clear_btn.button("Clear" ,use_container_width=True):
|
358 |
+
# streamlit_js_eval(js_expressions="parent.window.location.reload()")
|