Skip to content

Commit

Permalink
Merge pull request #33 from jpgtzg/feature/add-description-improvements
Browse files Browse the repository at this point in the history
Feature/add description improvements
  • Loading branch information
Pradyuman7 authored Feb 7, 2025
2 parents 63a18b3 + 563cc0e commit 019780c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
.pytest_cache/
__pycache__
.vscode
.env
.env
35 changes: 27 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from flask import Flask, jsonify, request
from models import Experience, Education, Skill
from gpt_connection import get_improvement
from validation import validate_experience, validate_education, validate_skill
from spell_check import spell_check

Expand All @@ -21,14 +22,13 @@
)
],
"education": [
Education(
"Computer Science",
"University of Tech",
"September 2019",
"July 2022",
"80%",
"example-logo.png",
)
Education("Computer Science",
"University of Tech",
"September 2019",
"July 2022",
"80%",
"example-logo.png",
"I was head of the debate team at university")
],
"skill": [Skill("Python", "1-2 Years", "example-logo.png")],
}
Expand Down Expand Up @@ -102,6 +102,25 @@ def education():
except ValueError as e:
return jsonify({"error": str(e)}), 400

@app.route('/resume/reword_description', methods=['GET'])
def reword_description():
'''
Rewords the description using GPT
'''
model = None
try:
model = Experience(**request.json)
except:
model = Education(**request.json)

if model is None:
return jsonify({"error": "Invalid request"}), 400

response = get_improvement(model)
if response is None:
return jsonify({"error": "Failed to get improvement"}), 500

return jsonify({"response": response})

@app.route("/resume/skill", methods=["GET", "POST"])
def skill():
Expand Down
31 changes: 31 additions & 0 deletions gpt_connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


from openai import OpenAI
import os
from dotenv import load_dotenv
from models import Experience, Education
load_dotenv()

client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY")
)

def get_improvement(model : Experience | Education):
prompt = f"Improve the following description for the {model.__class__.__name__}: {model.description}"

response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant that improves descriptions for resumes."},
{"role": "assistant", "content": "Here is the improved description:"},
{"role": "system", "content": f"Consider the following information about the {model.__class__.__name__}: {model.model_dump_json()}"},
{"role": "user", "content": prompt},
]
)
try:
return response.choices[0].message.content
except:
return None



13 changes: 13 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'''

from dataclasses import dataclass
import json


@dataclass
Expand All @@ -19,6 +20,11 @@ class Experience:
description: str
logo: str

def model_dump_json(self):
'''
Dumps the class into a JSON string
'''
return json.dumps(self, default=lambda o: o.__dict__)

@dataclass
class Education:
Expand All @@ -31,6 +37,13 @@ class Education:
end_date: str
grade: str
logo: str
description: str

def model_dump_json(self):
'''
Dumps the class into a JSON string
'''
return json.dumps(self, default=lambda o: o.__dict__)


@dataclass
Expand Down

0 comments on commit 019780c

Please sign in to comment.