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.
Merge pull request #33 from jpgtzg/feature/add-description-improvements
Feature/add description improvements
- Loading branch information
Showing
4 changed files
with
72 additions
and
9 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 |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
.pytest_cache/ | ||
__pycache__ | ||
.vscode | ||
.env | ||
.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