Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,16 +6,19 @@ import io
|
|
| 6 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 7 |
|
| 8 |
def pdf_to_text(pdf_file):
|
|
|
|
|
|
|
| 9 |
text = ""
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
return text
|
| 14 |
|
| 15 |
def update_resume(pdf_file):
|
| 16 |
-
|
| 17 |
-
return pdf_to_text(pdf_file)
|
| 18 |
-
return ""
|
| 19 |
|
| 20 |
def get_system_prompt(resume, job_description):
|
| 21 |
return f"""
|
|
@@ -57,7 +60,9 @@ def generate_question(history, resume, job_description):
|
|
| 57 |
return response.choices[0].message.content
|
| 58 |
|
| 59 |
def respond(message, history, resume, job_description):
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
|
| 62 |
with gr.Blocks() as demo:
|
| 63 |
gr.Markdown("# AI Job Interview Simulator")
|
|
|
|
| 6 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 7 |
|
| 8 |
def pdf_to_text(pdf_file):
|
| 9 |
+
if pdf_file is None:
|
| 10 |
+
return ""
|
| 11 |
text = ""
|
| 12 |
+
try:
|
| 13 |
+
pdf_reader = PyPDF2.PdfReader(pdf_file.name) # Use the file path instead of bytes
|
| 14 |
+
for page in pdf_reader.pages:
|
| 15 |
+
text += page.extract_text() + "\n"
|
| 16 |
+
except Exception as e:
|
| 17 |
+
text = f"Error reading PDF: {str(e)}"
|
| 18 |
return text
|
| 19 |
|
| 20 |
def update_resume(pdf_file):
|
| 21 |
+
return pdf_to_text(pdf_file)
|
|
|
|
|
|
|
| 22 |
|
| 23 |
def get_system_prompt(resume, job_description):
|
| 24 |
return f"""
|
|
|
|
| 60 |
return response.choices[0].message.content
|
| 61 |
|
| 62 |
def respond(message, history, resume, job_description):
|
| 63 |
+
bot_message = generate_question(history, resume, job_description)
|
| 64 |
+
history.append((message, bot_message))
|
| 65 |
+
return history, "" # Return updated history and empty the message box
|
| 66 |
|
| 67 |
with gr.Blocks() as demo:
|
| 68 |
gr.Markdown("# AI Job Interview Simulator")
|