generated from MLH-Fellowship/orientation-project-python
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
245 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
.venv | ||
.pytest_cache/ | ||
__pycache__ | ||
.vscode | ||
.vscode | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
Module for spell checking functionality using autocorrect library. | ||
""" | ||
|
||
from autocorrect import Speller | ||
|
||
spell = Speller(lang='en') | ||
|
||
def spell_check(text): | ||
''' | ||
Spell checks the text | ||
''' | ||
return spell(text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from models import Experience, Education, Skill | ||
|
||
def validate_experience(json_data: dict): | ||
''' | ||
Validates the experience | ||
''' | ||
if 'spell_check' in json_data: | ||
del json_data['spell_check'] | ||
try: | ||
return Experience(**json_data) | ||
except Exception as e: | ||
raise ValueError(f"Invalid experience format: {e}") | ||
|
||
def validate_education(json_data: dict): | ||
''' | ||
Validates the education | ||
''' | ||
if 'spell_check' in json_data: | ||
del json_data['spell_check'] | ||
try: | ||
return Education(**json_data) | ||
except Exception as e: | ||
raise ValueError(f"Invalid education format: {e}") | ||
|
||
def validate_skill(json_data: dict): | ||
''' | ||
Validates the skill | ||
''' | ||
if 'spell_check' in json_data: | ||
del json_data['spell_check'] | ||
try: | ||
return Skill(**json_data) | ||
except Exception as e: | ||
raise ValueError(f"Invalid skill format: {e}") | ||
|
||
|
||
data = { | ||
"experience": { | ||
"title": "Software Developer", | ||
"company": "A Cooler Company", | ||
"start_date": "October 2022", | ||
"end_date": "Present", | ||
"description": "Writing JavaScript Code", | ||
"logo": "example-logo.png", | ||
"spell_check": True | ||
}, | ||
"education": { | ||
"course": "Engineering", | ||
"school": "NYU", | ||
"start_date": "October 2022", | ||
"end_date": "August 2024", | ||
"grade": "86%", | ||
"logo": "example-logo.png", | ||
"description": "I was head of the debate team at university" | ||
}, | ||
"skill": { | ||
"name": "JavaScript", | ||
"proficiency": "2-4 years", | ||
"logo": "example-logo.png" | ||
} | ||
} | ||
|
||
print(validate_experience(data['experience'])) | ||
print(validate_education(data['education'])) | ||
print(validate_skill(data['skill'])) |