Added strip to prevent new line error
Browse files- resume_ai.py +37 -37
resume_ai.py
CHANGED
|
@@ -1,37 +1,37 @@
|
|
| 1 |
-
import os, json
|
| 2 |
-
from openai import AzureOpenAI
|
| 3 |
-
from dotenv import load_dotenv
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
load_dotenv()
|
| 7 |
-
client = AzureOpenAI(
|
| 8 |
-
api_key=os.getenv("AZURE_OPENAI_KEY"),
|
| 9 |
-
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
|
| 10 |
-
api_version=os.getenv("AZURE_OPENAI_VERSION")
|
| 11 |
-
)
|
| 12 |
-
DEPLOY = os.getenv("AZURE_OPENAI_DEPLOYMENT")
|
| 13 |
-
|
| 14 |
-
def score(resume, jd):
|
| 15 |
-
r = client.chat.completions.create(
|
| 16 |
-
model=DEPLOY,
|
| 17 |
-
max_completion_tokens=800,
|
| 18 |
-
temperature=0.8,
|
| 19 |
-
messages=[
|
| 20 |
-
{"role":"system","content":"Act as an ATS. Compare résumé with JD. Return JSON: overall_score(0-100) and category_scores{skills,experience,education}, plus top_skill_gaps list."},
|
| 21 |
-
{"role":"user","content":f"JOB_DESCRIPTION:\n{jd}\n\nRESUME:\n{resume}"}
|
| 22 |
-
]
|
| 23 |
-
)
|
| 24 |
-
return json.loads(r.choices[0].message.content.strip())
|
| 25 |
-
|
| 26 |
-
def improve(resume, jd=None):
|
| 27 |
-
p = ("Provide bullet suggestions to raise the score. " + ("Tailor to this JD:\n"+jd+"\n" if jd else "") + "Here is the résumé:\n"+resume)
|
| 28 |
-
r = client.chat.completions.create(
|
| 29 |
-
model=DEPLOY,
|
| 30 |
-
max_completion_tokens=800,
|
| 31 |
-
temperature=0.7,
|
| 32 |
-
messages=[
|
| 33 |
-
{"role":"system","content":"You are a résumé coach."},
|
| 34 |
-
{"role":"user","content":p}
|
| 35 |
-
]
|
| 36 |
-
)
|
| 37 |
-
return r.choices[0].message.content.strip()
|
|
|
|
| 1 |
+
import os, json
|
| 2 |
+
from openai import AzureOpenAI
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
client = AzureOpenAI(
|
| 8 |
+
api_key=os.getenv("AZURE_OPENAI_KEY").strip(),
|
| 9 |
+
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT").strip(),
|
| 10 |
+
api_version=os.getenv("AZURE_OPENAI_VERSION").strip()
|
| 11 |
+
)
|
| 12 |
+
DEPLOY = os.getenv("AZURE_OPENAI_DEPLOYMENT").strip()
|
| 13 |
+
|
| 14 |
+
def score(resume, jd):
|
| 15 |
+
r = client.chat.completions.create(
|
| 16 |
+
model=DEPLOY,
|
| 17 |
+
max_completion_tokens=800,
|
| 18 |
+
temperature=0.8,
|
| 19 |
+
messages=[
|
| 20 |
+
{"role":"system","content":"Act as an ATS. Compare résumé with JD. Return JSON: overall_score(0-100) and category_scores{skills,experience,education}, plus top_skill_gaps list."},
|
| 21 |
+
{"role":"user","content":f"JOB_DESCRIPTION:\n{jd}\n\nRESUME:\n{resume}"}
|
| 22 |
+
]
|
| 23 |
+
)
|
| 24 |
+
return json.loads(r.choices[0].message.content.strip())
|
| 25 |
+
|
| 26 |
+
def improve(resume, jd=None):
|
| 27 |
+
p = ("Provide bullet suggestions to raise the score. " + ("Tailor to this JD:\n"+jd+"\n" if jd else "") + "Here is the résumé:\n"+resume)
|
| 28 |
+
r = client.chat.completions.create(
|
| 29 |
+
model=DEPLOY,
|
| 30 |
+
max_completion_tokens=800,
|
| 31 |
+
temperature=0.7,
|
| 32 |
+
messages=[
|
| 33 |
+
{"role":"system","content":"You are a résumé coach."},
|
| 34 |
+
{"role":"user","content":p}
|
| 35 |
+
]
|
| 36 |
+
)
|
| 37 |
+
return r.choices[0].message.content.strip()
|