Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,52 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
# Configure the Generative AI model
|
| 6 |
-
genai.configure(api_key="AIzaSyBqPmsZAJrCsXme9wJBx9o4K71M9c1qzy8")
|
| 7 |
|
| 8 |
def ai_output(input_text, pdf_text, prompt):
|
| 9 |
-
model = genai.GenerativeModel('gemini-1.5-flash')
|
| 10 |
combined_input = f"{input_text}\n\n{pdf_text}\n\n{prompt}"
|
| 11 |
-
response =
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
def ai_ans(input_text, prompt):
|
| 15 |
-
model = genai.GenerativeModel('gemini-1.5-flash')
|
| 16 |
combined_input = f"{input_text}\n\n{prompt}"
|
| 17 |
-
response =
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
def input_pdf_setup(uploaded_file):
|
| 21 |
if uploaded_file is not None:
|
| 22 |
pdf_document = fitz.open(stream=uploaded_file.read(), filetype="pdf")
|
| 23 |
-
text = ""
|
| 24 |
-
for page_num in range(len(pdf_document)):
|
| 25 |
-
page = pdf_document.load_page(page_num)
|
| 26 |
-
text += page.get_text()
|
| 27 |
pdf_document.close()
|
| 28 |
return text
|
| 29 |
else:
|
|
@@ -71,16 +94,12 @@ You are an advanced career advisor and job market expert with deep insights into
|
|
| 71 |
input_prompt4 = """
|
| 72 |
You are an expert in resume optimization and keyword integration for job applications. I am providing my resume content along with a job description. Your task is to analyze the resume and identify any important keywords or skills from the job description that are missing in my resume. For each missing keyword or skill, provide the following:
|
| 73 |
|
| 74 |
-
1.A clear explanation of all the missing
|
| 75 |
-
2.A detailed suggestion for a sentence or bullet point that can be added to the resume to include the missing keyword.
|
| 76 |
-
3.Guidance on where in the resume (e.g., Professional Experience, Skills, Education, Projects) the new content should be inserted for the best impact.
|
| 77 |
-
Ensure that the suggestions are tailored to the context of my existing resume, maintaining a natural flow and relevance to my career background
|
| 78 |
-
and also tell that you experience is less that what this job is expected
|
| 79 |
-
|
| 80 |
-
also get the list of missing keywords
|
| 81 |
-
|
| 82 |
-
and tell me why I would not select for an interview for this position according to my resume
|
| 83 |
|
|
|
|
|
|
|
| 84 |
"""
|
| 85 |
|
| 86 |
if submit1:
|
|
@@ -106,5 +125,3 @@ elif submit4:
|
|
| 106 |
response = ai_output(input_text, pdf_text, input_prompt4)
|
| 107 |
st.subheader("Missing things which need to be present in your resume:")
|
| 108 |
st.write(response)
|
| 109 |
-
|
| 110 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
+
import requests
|
| 4 |
+
import json
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def ai_output(input_text, pdf_text, prompt):
|
|
|
|
| 7 |
combined_input = f"{input_text}\n\n{pdf_text}\n\n{prompt}"
|
| 8 |
+
response = requests.post(
|
| 9 |
+
url="https://api.aimlapi.com/chat/completions",
|
| 10 |
+
headers={
|
| 11 |
+
"Authorization": "Bearer abc_api_key_xyz",
|
| 12 |
+
"Content-Type": "application/json",
|
| 13 |
+
},
|
| 14 |
+
data=json.dumps(
|
| 15 |
+
{
|
| 16 |
+
"model": "gpt-4o",
|
| 17 |
+
"messages": [{"role": "user", "content": combined_input}],
|
| 18 |
+
"max_tokens": 512,
|
| 19 |
+
"stream": False,
|
| 20 |
+
}
|
| 21 |
+
),
|
| 22 |
+
)
|
| 23 |
+
response.raise_for_status()
|
| 24 |
+
return response.json().get("choices", [{}])[0].get("message", {}).get("content", "Error: No response")
|
| 25 |
|
| 26 |
def ai_ans(input_text, prompt):
|
|
|
|
| 27 |
combined_input = f"{input_text}\n\n{prompt}"
|
| 28 |
+
response = requests.post(
|
| 29 |
+
url="https://api.aimlapi.com/chat/completions",
|
| 30 |
+
headers={
|
| 31 |
+
"Authorization": "Bearer abc_api_key_xyz",
|
| 32 |
+
"Content-Type": "application/json",
|
| 33 |
+
},
|
| 34 |
+
data=json.dumps(
|
| 35 |
+
{
|
| 36 |
+
"model": "gpt-4o",
|
| 37 |
+
"messages": [{"role": "user", "content": combined_input}],
|
| 38 |
+
"max_tokens": 512,
|
| 39 |
+
"stream": False,
|
| 40 |
+
}
|
| 41 |
+
),
|
| 42 |
+
)
|
| 43 |
+
response.raise_for_status()
|
| 44 |
+
return response.json().get("choices", [{}])[0].get("message", {}).get("content", "Error: No response")
|
| 45 |
|
| 46 |
def input_pdf_setup(uploaded_file):
|
| 47 |
if uploaded_file is not None:
|
| 48 |
pdf_document = fitz.open(stream=uploaded_file.read(), filetype="pdf")
|
| 49 |
+
text = "".join(page.get_text() for page in pdf_document)
|
|
|
|
|
|
|
|
|
|
| 50 |
pdf_document.close()
|
| 51 |
return text
|
| 52 |
else:
|
|
|
|
| 94 |
input_prompt4 = """
|
| 95 |
You are an expert in resume optimization and keyword integration for job applications. I am providing my resume content along with a job description. Your task is to analyze the resume and identify any important keywords or skills from the job description that are missing in my resume. For each missing keyword or skill, provide the following:
|
| 96 |
|
| 97 |
+
1. A clear explanation of all the missing keywords or skills and why they are important for the role.
|
| 98 |
+
2. A detailed suggestion for a sentence or bullet point that can be added to the resume to include the missing keyword.
|
| 99 |
+
3. Guidance on where in the resume (e.g., Professional Experience, Skills, Education, Projects) the new content should be inserted for the best impact.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
+
Ensure that the suggestions are tailored to the context of my existing resume, maintaining a natural flow and relevance to my career background.
|
| 102 |
+
Also, tell me why I would not be selected for an interview for this position according to my resume.
|
| 103 |
"""
|
| 104 |
|
| 105 |
if submit1:
|
|
|
|
| 125 |
response = ai_output(input_text, pdf_text, input_prompt4)
|
| 126 |
st.subheader("Missing things which need to be present in your resume:")
|
| 127 |
st.write(response)
|
|
|
|
|
|