forked from nehajaideep/WolfTrack3.0
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #17 from aniketdarp190301/chatGPT_pipeline
- Loading branch information
Showing
6 changed files
with
265 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from PyPDF2 import PdfReader | ||
import numpy as np | ||
import requests | ||
import os | ||
import openai | ||
|
||
|
||
def pdf_to_text(pdf_path, text_path): | ||
with open(pdf_path, 'rb') as pdf_file: | ||
# Create a PDF reader object | ||
pdf_reader = PdfReader(pdf_file) | ||
|
||
# Initialize an empty string to store the text | ||
text = "" | ||
|
||
# Iterate through each page of the PDF | ||
for page_num in range(len(pdf_reader.pages)): | ||
# Extract text from the current page | ||
text += pdf_reader.pages[page_num].extract_text() | ||
|
||
# Open a text file in write mode and save the extracted text | ||
with open(text_path, 'w', encoding='utf-8') as text_file: | ||
text_file.write(text) | ||
|
||
|
||
# chatgpt pipeline | ||
def chatgpt(resume_textfile_path): | ||
with open(resume_textfile_path, 'r') as file: | ||
content = file.read() | ||
openai_api_key = os.environ.get('OPENAI_API_KEY') | ||
|
||
# Set the API endpoint | ||
api_url = "https://api.openai.com/v1/chat/completions" | ||
|
||
# Set the request headers | ||
headers = { | ||
"Content-Type": "application/json", | ||
"Authorization": f"Bearer {openai_api_key}" | ||
} | ||
|
||
# Set the request payload | ||
payload = { | ||
"model": "gpt-3.5-turbo", | ||
"messages": [{"role":"system","content":"critique the following resume text on the basis of its conciseness, use of action words and numbers. Give suggestions on the 1. education section, then the 2. experiences section, then the 3. skills section and finally the 4. projects section. Give these suggestions on these four sections in the form of four paragraphs and label them Section 1, Section 2, Section 3 and Section 4 respectively, each separated by a line. Make sure each paragraph is atleast 50-70 words long."},{"role": "user", "content": content}], | ||
"temperature": 0.7 | ||
} | ||
|
||
# Make the POST request | ||
try: | ||
response = requests.post(api_url, json=payload, headers=headers) | ||
|
||
# Check if the request was successful (status code 200) | ||
if response.status_code == 200: | ||
# Print or process the response content | ||
print("API Response:") | ||
json_data = response.json() | ||
final_suggestions = json_data['choices'][0]['message']['content'] | ||
# print(final_suggestions) | ||
return final_suggestions | ||
else: | ||
print(f"Error: {response.status_code}") | ||
print(response.text) | ||
|
||
except Exception as e: | ||
print(f"An error occurred: {e}") | ||
|
||
|
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,151 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>JavaScript example</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" /> | ||
|
||
<!-- Bootstrap --> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" | ||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" /> | ||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" | ||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" | ||
crossorigin="anonymous"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" | ||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" | ||
crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" | ||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" | ||
crossorigin="anonymous"></script> | ||
|
||
<link rel="stylesheet" href="{{ url_for('static', filename='css/layout.css') }}" /> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='css/admin.css') }}" /> | ||
<style media="only screen"> | ||
html, | ||
body { | ||
height: 100%; | ||
width: 100%; | ||
margin: 0; | ||
box-sizing: border-box; | ||
-webkit-overflow-scrolling: touch; | ||
} | ||
|
||
html { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
padding: 0; | ||
overflow: auto; | ||
} | ||
|
||
body { | ||
overflow: auto; | ||
} | ||
|
||
#myElement { | ||
color: black; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
/* Use flexbox to arrange the divs horizontally */ | ||
justify-content: space-between; | ||
/* Spread the divs evenly in the container */ | ||
} | ||
|
||
.card { | ||
/* Add any additional styling for your cards here */ | ||
margin: 10px; | ||
/* Optional margin between the cards */ | ||
} | ||
|
||
.text-black { | ||
color: black; | ||
} | ||
|
||
.row { | ||
height: 100vh; | ||
/* Make the row take up the full viewport height */ | ||
} | ||
</style> | ||
</head> | ||
|
||
<body></body> | ||
|
||
<body> | ||
<nav class="navbar navbar-expand-sm navbar-dark sticky-top"> | ||
<ul class="navbar-nav"> | ||
<img class="rounded-circle project-icon" alt="100x100" | ||
src="https://ih1.redbubble.net/image.1703296696.9941/st,small,507x507-pad,600x600,f8f8f8.jpg" | ||
height="30px" width="30px" style="margin-right: 5px; margin-top: 5px" data-holder-rendered="true" /> | ||
<a class="navbar-brand" href="/">WolfTrack</a> | ||
</ul> | ||
<ul class="navbar-nav ml-auto"> | ||
<a href="/resumeAnalyzer" style="color: #facaca; text-decoration: none">Analyze Resume</a> | ||
</ul> | ||
<ul class="navbar-nav ml-auto"> | ||
<a href="/findJobs" style="color: #facaca; text-decoration: none">Recommended Jobs</a> | ||
</ul> | ||
<ul class="navbar-nav ml-auto"> | ||
<a href="/chat_gpt_analyzer" style="color: #facaca; text-decoration: none">Resume Suggestions</a> | ||
</ul> | ||
<ul class="navbar-nav ml-auto"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/logout">Logout</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
<h1 id="myElement">Suggestions:</h1> | ||
<div class="row"> | ||
<div class="col-3"> | ||
<div class="card" style="width: 18rem;"> | ||
<div class="card-body"> | ||
<h5 class="card-title text-black">{{section_names[0]}}</h5> | ||
<p class="card-text text-black">{{suggestions[0]}}</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-3"> | ||
<div class="card" style="width: 18rem;"> | ||
<div class="card-body"> | ||
<h5 class="card-title text-black">{{section_names[1]}}</h5> | ||
<p class="card-text text-black">{{suggestions[1]}}</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-3"> | ||
<div class="card" style="width: 18rem;"> | ||
<div class="card-body"> | ||
<h5 class="card-title text-black">{{section_names[2]}}</h5> | ||
<p class="card-text text-black">{{suggestions[2]}}</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-3"> | ||
<div class="card" style="width: 18rem;"> | ||
<div class="card-body"> | ||
<h5 class="card-title text-black">{{section_names[3]}}</h5> | ||
<p class="card-text text-black">{{suggestions[3]}}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<!-- </ul> --> | ||
</body> | ||
|
||
</html> |
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
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