Spaces:
Sleeping
Sleeping
Aditya Patkar
commited on
Commit
•
0cae9a4
1
Parent(s):
94c47e8
Saving generation conversations to log file
Browse files- app.py +28 -8
- constants.py +7 -0
- conversation.txt +144 -0
- cover_letter_generator.py +2 -2
- documents/resume_0.docx +0 -0
- documents/resume_0.pdf +0 -0
- interview_questions_generator.py +3 -1
- job_description_fixer.py +2 -1
- job_description_generator.py +2 -2
- loaders.py +26 -4
app.py
CHANGED
@@ -14,9 +14,15 @@ from interview_questions_generator import (predict_interview_question,
|
|
14 |
get_interview_questions_conversation)
|
15 |
from cover_letter_generator import get_cover_letter
|
16 |
from top_accomplishment_generator import get_accomplishments
|
|
|
17 |
|
18 |
conversation = get_job_description_conversation()
|
19 |
if 'generator_conversation' not in st.session_state:
|
|
|
|
|
|
|
|
|
|
|
20 |
st.session_state['generator_conversation'] = conversation
|
21 |
|
22 |
fixer_conversation = get_job_description_fixer_conversation()
|
@@ -33,7 +39,7 @@ def get_downloadable_conversation(input_text, response):
|
|
33 |
'''
|
34 |
Downloads the conversation to a text file.
|
35 |
'''
|
36 |
-
conversation_to_save = f"Conversation with JobGPT on {datetime.datetime.now()}: \n\n"
|
37 |
for historical_message in response['history']:
|
38 |
conversation_to_save = conversation_to_save + historical_message + "\n"
|
39 |
conversation_to_save = conversation_to_save + f"Human: {input_text} \n"
|
@@ -48,6 +54,7 @@ def message_writer(input_text, response):
|
|
48 |
messages = []
|
49 |
current_message = ""
|
50 |
current_is_user = True
|
|
|
51 |
for historical_message in response['history']:
|
52 |
if "human" in historical_message.lower():
|
53 |
messages.append([current_message, current_is_user])
|
@@ -116,7 +123,7 @@ def main():
|
|
116 |
"JobGPT is a chatbot that generates job descriptions. \
|
117 |
This is built just for demo purpose."
|
118 |
)
|
119 |
-
input_text = container_one.
|
120 |
"Prompt",
|
121 |
"Hi, can you please help me generate an unbiased job description?")
|
122 |
button = container_one.button("Send")
|
@@ -128,6 +135,11 @@ def main():
|
|
128 |
clear_session = st.sidebar.button("New Chat")
|
129 |
|
130 |
if clear_session:
|
|
|
|
|
|
|
|
|
|
|
131 |
st.session_state['generator_conversation'] = conversation
|
132 |
container_one.markdown("---")
|
133 |
|
@@ -143,6 +155,11 @@ def main():
|
|
143 |
conversation_to_save = get_downloadable_conversation(
|
144 |
input_text, st.session_state['response'])
|
145 |
|
|
|
|
|
|
|
|
|
|
|
146 |
#download the conversation
|
147 |
b64 = base64.b64encode(conversation_to_save.encode()).decode()
|
148 |
href = f'<a href="data:file/txt;base64,{b64}" download="{datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")}-conversation.txt">Download conversation</a>'
|
@@ -192,11 +209,14 @@ def main():
|
|
192 |
container_three.markdown( "JobGPT is a chatbot that generates cover letters. \
|
193 |
This is built just for demo purpose.")
|
194 |
container_three.markdown("---")
|
195 |
-
|
196 |
-
if
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
200 |
with st.spinner('Uploading...'):
|
201 |
time.sleep(1)
|
202 |
container_three.success('Uploaded!')
|
@@ -215,7 +235,7 @@ def main():
|
|
215 |
st.error("Please enter a company name")
|
216 |
else:
|
217 |
with st.spinner('Generating...'):
|
218 |
-
cover_letter = get_cover_letter(title, company, more_info, "
|
219 |
container_three.markdown("---")
|
220 |
container_three.markdown("### Cover Letter:")
|
221 |
container_three.write(cover_letter)
|
|
|
14 |
get_interview_questions_conversation)
|
15 |
from cover_letter_generator import get_cover_letter
|
16 |
from top_accomplishment_generator import get_accomplishments
|
17 |
+
from constants import PROMPT_VERSION
|
18 |
|
19 |
conversation = get_job_description_conversation()
|
20 |
if 'generator_conversation' not in st.session_state:
|
21 |
+
with open("./conversation.txt", "a", encoding='utf-8') as f:
|
22 |
+
#add a horizontal line
|
23 |
+
f.write("--------------------------------------------------\n")
|
24 |
+
#add the date
|
25 |
+
f.write(f"Conversation on {datetime.datetime.now()}, prompt_{PROMPT_VERSION}: \n\n")
|
26 |
st.session_state['generator_conversation'] = conversation
|
27 |
|
28 |
fixer_conversation = get_job_description_fixer_conversation()
|
|
|
39 |
'''
|
40 |
Downloads the conversation to a text file.
|
41 |
'''
|
42 |
+
conversation_to_save = f"Conversation with JobGPT on {datetime.datetime.now()}, prompt_{PROMPT_VERSION}: \n\n"
|
43 |
for historical_message in response['history']:
|
44 |
conversation_to_save = conversation_to_save + historical_message + "\n"
|
45 |
conversation_to_save = conversation_to_save + f"Human: {input_text} \n"
|
|
|
54 |
messages = []
|
55 |
current_message = ""
|
56 |
current_is_user = True
|
57 |
+
|
58 |
for historical_message in response['history']:
|
59 |
if "human" in historical_message.lower():
|
60 |
messages.append([current_message, current_is_user])
|
|
|
123 |
"JobGPT is a chatbot that generates job descriptions. \
|
124 |
This is built just for demo purpose."
|
125 |
)
|
126 |
+
input_text = container_one.text_area(
|
127 |
"Prompt",
|
128 |
"Hi, can you please help me generate an unbiased job description?")
|
129 |
button = container_one.button("Send")
|
|
|
135 |
clear_session = st.sidebar.button("New Chat")
|
136 |
|
137 |
if clear_session:
|
138 |
+
with open("./conversation.txt", "a", encoding='utf-8') as f:
|
139 |
+
#add a horizontal line
|
140 |
+
f.write("--------------------------------------------------\n")
|
141 |
+
#add the date
|
142 |
+
f.write(f"Conversation on {datetime.datetime.now()}, prompt_{PROMPT_VERSION}: \n\n")
|
143 |
st.session_state['generator_conversation'] = conversation
|
144 |
container_one.markdown("---")
|
145 |
|
|
|
155 |
conversation_to_save = get_downloadable_conversation(
|
156 |
input_text, st.session_state['response'])
|
157 |
|
158 |
+
#write to conversation.txt
|
159 |
+
with open("./conversation.txt", "a", encoding='utf-8') as f:
|
160 |
+
f.write(f"HUMAN: {input_text}\n")
|
161 |
+
f.write(f"BOT: {response['prediction']}\n")
|
162 |
+
|
163 |
#download the conversation
|
164 |
b64 = base64.b64encode(conversation_to_save.encode()).decode()
|
165 |
href = f'<a href="data:file/txt;base64,{b64}" download="{datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")}-conversation.txt">Download conversation</a>'
|
|
|
209 |
container_three.markdown( "JobGPT is a chatbot that generates cover letters. \
|
210 |
This is built just for demo purpose.")
|
211 |
container_three.markdown("---")
|
212 |
+
uploaded_files = container_three.file_uploader("Upload your resume", type=["pdf", "txt", "docx"], accept_multiple_files=True)
|
213 |
+
if uploaded_files is not None and uploaded_files != []:
|
214 |
+
counter = 0
|
215 |
+
for uploaded_file in uploaded_files:
|
216 |
+
file_extension = uploaded_file.name.split(".")[-1]
|
217 |
+
with open(f"./documents/resume_{counter}.{file_extension}", "wb") as file_io:
|
218 |
+
file_io.write(uploaded_file.getbuffer())
|
219 |
+
counter += 1
|
220 |
with st.spinner('Uploading...'):
|
221 |
time.sleep(1)
|
222 |
container_three.success('Uploaded!')
|
|
|
235 |
st.error("Please enter a company name")
|
236 |
else:
|
237 |
with st.spinner('Generating...'):
|
238 |
+
cover_letter = get_cover_letter(title, company, more_info, "./documents")
|
239 |
container_three.markdown("---")
|
240 |
container_three.markdown("### Cover Letter:")
|
241 |
container_three.write(cover_letter)
|
constants.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'''
|
2 |
+
This file contains all the constants used in the project.
|
3 |
+
'''
|
4 |
+
|
5 |
+
TEMPERATURE = 0.7
|
6 |
+
MODEL_NAME = "gpt-3.5-turbo-16k"
|
7 |
+
PROMPT_VERSION = "v2"
|
conversation.txt
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
--------------------------------------------------
|
2 |
+
Conversation on 2023-06-22 10:36:48.567216, prompt_v2:
|
3 |
+
|
4 |
+
HUMAN: Hi, can you please help me generate an unbiased job description?
|
5 |
+
BOT: Of course! I'd be happy to help you generate an unbiased job description. Could you please provide me with the title of the position you're hiring for?
|
6 |
+
HUMAN: Director, Data Science
|
7 |
+
BOT: Great! Could you also let me know the industry for this position?
|
8 |
+
HUMAN: Tourism
|
9 |
+
BOT: Thank you for providing the industry. Now, could you please let me know the location for this position?
|
10 |
+
HUMAN: Dallas, Hybrid
|
11 |
+
BOT: Thank you for providing the location. Now, could you please let me know the type of role for this position? Is it remote, hybrid, or on-site?
|
12 |
+
HUMAN: Hybrid
|
13 |
+
BOT: Thank you for providing the type of role. Now, could you please let me know the top goals the hire is expected to achieve in this role?
|
14 |
+
HUMAN: Develop predictive models, Provide expertise in data wrangling and exploratory data analysis
|
15 |
+
BOT: Thank you for providing the top goals for this role. Now, could you please let me know the top accomplishments of the hire in their previous roles?
|
16 |
+
HUMAN: Delivered multiple data science and machine learning projects over 8+ years with values exceeding $10 Million or more and has worked on platform members exceeding 10 million lives
|
17 |
+
• 9+ years of industry experience in data science, machine learning, and artificial intelligence
|
18 |
+
BOT: Thank you for providing the top accomplishments for the hire. Now, could you please let me know the size of the company the individual would come from?
|
19 |
+
|
20 |
+
HUMAN: $2 Billion
|
21 |
+
BOT: Thank you for providing the size of the company. Now, let's move on to the salary. Do you have a specific number in mind for the salary, or should I estimate it for you based on the context and knowledge I have?
|
22 |
+
HUMAN: Estimate it
|
23 |
+
BOT: Based on the context and knowledge I have, I would estimate the salary and equity package for the Director, Data Science position in the Tourism industry in Dallas, with a hybrid role. The estimated salary for this position would be in the range of $150,000 to $200,000 per year, depending on the candidate's experience, qualifications, and the size of the company they are coming from. The equity package would be negotiable and can be discussed further during the hiring process.
|
24 |
+
|
25 |
+
Now, let's move on to the non-negotiable requirements for this role. Could you please provide me with any specific skills, qualifications, or experience that are essential for the candidate to have?
|
26 |
+
HUMAN: Expertise in healthcare privacy, federated learning, continuous integration and deployment, DevOps support
|
27 |
+
• 3+ Years of experience managing directly five (5) or more senior level data scientists, machine learning engineers with advanced degrees and directly
|
28 |
+
|
29 |
+
BOT: Thank you for providing the non-negotiable requirements for this role.
|
30 |
+
|
31 |
+
Based on the information provided, here's the job description for the Director, Data Science position in the Tourism industry:
|
32 |
+
|
33 |
+
Job Title:
|
34 |
+
Director, Data Science
|
35 |
+
|
36 |
+
Company Name:
|
37 |
+
[Company Name]
|
38 |
+
|
39 |
+
About Us:
|
40 |
+
[Provide information about the company, its mission, and values.]
|
41 |
+
|
42 |
+
About the Job:
|
43 |
+
As the Director of Data Science, you will be responsible for leading and managing the data science team. You will play a key role in developing predictive models and providing expertise in data wrangling and exploratory data analysis.
|
44 |
+
|
45 |
+
Day to Day Responsibilities:
|
46 |
+
- Manage and mentor a team of senior-level data scientists and machine learning engineers, providing guidance and support in their projects
|
47 |
+
- Collaborate with cross-functional teams to identify and prioritize business needs and translate them into data science initiatives
|
48 |
+
- Develop and implement strategies for data collection, preprocessing, and feature engineering
|
49 |
+
- Conduct statistical analysis and apply machine learning algorithms to solve complex business problems
|
50 |
+
- Communicate findings and insights to stakeholders in a clear and actionable manner
|
51 |
+
- Stay up-to-date with the latest trends and advancements in data science and machine learning
|
52 |
+
|
53 |
+
Goals:
|
54 |
+
- Develop predictive models to drive data-driven decision making
|
55 |
+
- Provide expertise in data wrangling and exploratory data analysis to uncover insights
|
56 |
+
- Drive innovation and continuous improvement in data science practices
|
57 |
+
- Collaborate with stakeholders to identify and prioritize business needs and deliver impactful solutions
|
58 |
+
|
59 |
+
Non-Negotiables:
|
60 |
+
- Expertise in healthcare privacy, federated learning, continuous integration and deployment, and DevOps support
|
61 |
+
- At least 3 years of experience managing directly five or more senior-level data scientists and machine learning engineers with advanced degrees
|
62 |
+
|
63 |
+
Beneficial Qualifications:
|
64 |
+
[List any additional skills, qualifications, or experience that would be beneficial but not essential for the role.]
|
65 |
+
|
66 |
+
Salary:
|
67 |
+
The estimated salary for this position would be in the range of $150,000 to $200,000 per year, depending on the candidate's experience, qualifications, and the size of the company they are coming from. The equity package would be negotiable and can be discussed further during the hiring process.
|
68 |
+
|
69 |
+
Legal Writeup:
|
70 |
+
[Include a statement underlining the company's commitment to diversity, equality, and inclusion.]
|
71 |
+
|
72 |
+
Please review the job description and let me know if you would like any changes or additions.
|
73 |
+
|
74 |
+
--------------------------------------------------
|
75 |
+
Conversation on 2023-06-22 10:46:48.567216, prompt_v2:
|
76 |
+
HUMAN: Hello, hiring a VP of Marketing in Los Angeles.
|
77 |
+
BOT: Hi there! Thank you for reaching out. I'd be happy to assist you in finding a VP of Marketing in Los Angeles. Could you please provide me with some more details about the role? Specifically, what industry is your company in?
|
78 |
+
HUMAN: Healthcare
|
79 |
+
BOT: Great! Thank you for providing the industry information. Now, could you please let me know if the role will be remote, hybrid, or on-site?
|
80 |
+
HUMAN: Hybrid
|
81 |
+
BOT: Thank you for letting me know that the role will be hybrid. Now, could you please share the top goals you expect the VP of Marketing to achieve in this role?
|
82 |
+
HUMAN: Establish a road map to achieve long range strategic marketing goals, Lead a team of 50, Identify and facilitate possible new categories or products
|
83 |
+
BOT: Thank you for providing the top goals for the VP of Marketing role. Now, could you please share the top accomplishments you would like to see in the candidate's previous roles?
|
84 |
+
HUMAN: 20-30% increase in website hits at a previous role, satisfactory product margins and market share in relation to preset standards and industry and economic trends
|
85 |
+
BOT: Thank you for sharing the top accomplishments you would like to see in the candidate's previous roles. Could you please let me know the size of the company the individual would come from?
|
86 |
+
HUMAN: 50-100 employees
|
87 |
+
BOT: Thank you for providing the size of the company. Lastly, could you please let me know the salary range for this position? If you don't have a specific number in mind, I can estimate the salary and equity package based on the context and knowledge I have.
|
88 |
+
HUMAN: I don't have a number in mind.
|
89 |
+
BOT: Based on the information provided, I will estimate the salary and equity package for the VP of Marketing position. Now, let's move on to the non-negotiable requirements for the role. Could you please share any specific qualifications or skills that are essential for this position?
|
90 |
+
HUMAN: MBA or equivalent from a top university with 15-20 years of related marketing experience and/or training.
|
91 |
+
A background in the healthcare, retail or consumer package goods industry is a strong plus
|
92 |
+
BOT: Thank you for providing the non-negotiable requirements for the VP of Marketing role. Lastly, could you please tell me a bit about your company? The name, culture, values, and any other relevant information would be helpful in generating a comprehensive job description.
|
93 |
+
HUMAN: Munchkin is one of the most innovative and fast-growing consumer product companies in the world! With over 320+ patents under our belt, we continue to create solutions that leave our customers asking, "how did I ever live without this?" Recognized as #8 on America’s Most Innovative Companies list by Fortune Magazine, innovation is the core of our company DNA and has been driving our designs for 30 years!
|
94 |
+
BOT: Thank you for providing information about your company, Munchkin. As one of the most innovative and fast-growing consumer product companies in the world, Munchkin has a strong focus on creating solutions that leave customers amazed. With over 320+ patents and 30 years of experience, innovation is at the core of Munchkin's DNA. Recognized as #8 on America's Most Innovative Companies list by Fortune Magazine, Munchkin continues to drive designs that make customers wonder how they ever lived without them.
|
95 |
+
|
96 |
+
Based on the information you've provided, here is the job description for the VP of Marketing position at Munchkin:
|
97 |
+
|
98 |
+
Job Title: VP of Marketing
|
99 |
+
Company: Munchkin
|
100 |
+
|
101 |
+
About Us:
|
102 |
+
Munchkin is one of the most innovative and fast-growing consumer product companies in the world! With over 320+ patents under our belt, we continue to create solutions that leave our customers asking, "how did I ever live without this?" Recognized as #8 on America's Most Innovative Companies list by Fortune Magazine, innovation is the core of our company DNA and has been driving our designs for 30 years!
|
103 |
+
|
104 |
+
About the Job:
|
105 |
+
As the VP of Marketing at Munchkin, you will play a crucial role in driving the company's marketing strategies and initiatives. You will have the opportunity to lead a team of 50 talented individuals and establish a roadmap to achieve long-range strategic marketing goals. Your expertise in identifying and facilitating possible new categories or products will contribute to Munchkin's continued growth and success.
|
106 |
+
|
107 |
+
Day-to-Day Responsibilities:
|
108 |
+
- Develop and execute comprehensive marketing strategies to drive brand awareness and increase market share
|
109 |
+
- Collaborate with cross-functional teams to align marketing initiatives with overall business objectives
|
110 |
+
- Lead and mentor a team of 50 marketing professionals, fostering a collaborative and results-driven culture
|
111 |
+
- Conduct market research and analysis to identify new opportunities and consumer trends
|
112 |
+
- Establish and maintain relationships with key stakeholders, including external agencies and partners
|
113 |
+
- Oversee the development of marketing campaigns, ensuring they are aligned with brand guidelines and objectives
|
114 |
+
- Monitor and analyze marketing performance metrics, making data-driven decisions to optimize campaigns
|
115 |
+
|
116 |
+
Goals:
|
117 |
+
- Establish a roadmap to achieve long-range strategic marketing goals
|
118 |
+
- Lead a team of 50 marketing professionals to drive brand awareness and increase market share
|
119 |
+
- Identify and facilitate possible new categories or products to contribute to the company's growth
|
120 |
+
|
121 |
+
Non-Negotiables:
|
122 |
+
- MBA or equivalent from a top university
|
123 |
+
- 15-20 years of related marketing experience and/or training
|
124 |
+
- Background in the healthcare, retail, or consumer package goods industry is a strong plus
|
125 |
+
|
126 |
+
Beneficial Qualifications:
|
127 |
+
- Proven track record of successfully driving marketing initiatives and achieving measurable results
|
128 |
+
- Strong strategic thinking and leadership skills
|
129 |
+
- Excellent communication and interpersonal abilities
|
130 |
+
- In-depth knowledge of digital marketing strategies and platforms
|
131 |
+
- Familiarity with market research and analysis techniques
|
132 |
+
|
133 |
+
Salary:
|
134 |
+
The salary and equity package for the VP of Marketing position will be commensurate with experience and industry standards.
|
135 |
+
|
136 |
+
At Munchkin, we are committed to fostering an inclusive and diverse work environment. We value equality and strive to create a workplace that offers equal opportunities for all individuals, regardless of gender, ethnicity, disability, or age. We believe that diversity fuels innovation and drives our success.
|
137 |
+
|
138 |
+
Please let me know if you have any other questions or if there's anything else I can assist you with!
|
139 |
+
--------------------------------------------------
|
140 |
+
Conversation on 2023-06-22 10:54:32.840043, prompt_v2:
|
141 |
+
|
142 |
+
--------------------------------------------------
|
143 |
+
Conversation on 2023-06-22 15:33:03.997792, prompt_v2:
|
144 |
+
|
cover_letter_generator.py
CHANGED
@@ -8,12 +8,12 @@ def generate_query(title:str, company:str, more_info = None):
|
|
8 |
'''
|
9 |
Generate a query from a title and company
|
10 |
'''
|
11 |
-
query = f"Write a professional and well-formatted cover letter based on the given resume for the job of {title} at {company}.\n"
|
12 |
if more_info:
|
13 |
query += f"More info: {more_info}\n"
|
14 |
return query
|
15 |
|
16 |
-
def get_cover_letter(title:str, company:str, more_info = None, resume_path = "
|
17 |
'''
|
18 |
Generate a cover letter from a title and company
|
19 |
'''
|
|
|
8 |
'''
|
9 |
Generate a query from a title and company
|
10 |
'''
|
11 |
+
query = f"Write a professional and well-formatted cover letter based on the given resume for the job description provided of the position {title} at {company}.\n"
|
12 |
if more_info:
|
13 |
query += f"More info: {more_info}\n"
|
14 |
return query
|
15 |
|
16 |
+
def get_cover_letter(title:str, company:str, more_info = None, resume_path = "documents"):
|
17 |
'''
|
18 |
Generate a cover letter from a title and company
|
19 |
'''
|
documents/resume_0.docx
ADDED
Binary file (8.1 kB). View file
|
|
documents/resume_0.pdf
ADDED
Binary file (230 kB). View file
|
|
interview_questions_generator.py
CHANGED
@@ -3,6 +3,8 @@ import openai
|
|
3 |
from langchain.chat_models import ChatOpenAI
|
4 |
from langchain.memory import ConversationBufferMemory
|
5 |
from llm import generate_prompt, generate_conversation, predict
|
|
|
|
|
6 |
|
7 |
openai_api_key = os.environ['OPENAI_API_KEY']
|
8 |
openai.api_key = openai_api_key
|
@@ -15,7 +17,7 @@ def get_interview_questions_conversation():
|
|
15 |
prompt = generate_prompt(
|
16 |
input_variables=['history', 'input'],
|
17 |
template_file='templates/interview_question_generator.txt')
|
18 |
-
llm = ChatOpenAI(temperature=
|
19 |
memory = ConversationBufferMemory(ai_prefix="JobGPT")
|
20 |
conversation = generate_conversation(memory=memory, llm=llm, prompt=prompt)
|
21 |
return conversation
|
|
|
3 |
from langchain.chat_models import ChatOpenAI
|
4 |
from langchain.memory import ConversationBufferMemory
|
5 |
from llm import generate_prompt, generate_conversation, predict
|
6 |
+
from constants import TEMPERATURE, MODEL_NAME
|
7 |
+
|
8 |
|
9 |
openai_api_key = os.environ['OPENAI_API_KEY']
|
10 |
openai.api_key = openai_api_key
|
|
|
17 |
prompt = generate_prompt(
|
18 |
input_variables=['history', 'input'],
|
19 |
template_file='templates/interview_question_generator.txt')
|
20 |
+
llm = ChatOpenAI(temperature=TEMPERATURE, openai_api_key=openai_api_key, model=MODEL_NAME)
|
21 |
memory = ConversationBufferMemory(ai_prefix="JobGPT")
|
22 |
conversation = generate_conversation(memory=memory, llm=llm, prompt=prompt)
|
23 |
return conversation
|
job_description_fixer.py
CHANGED
@@ -7,6 +7,7 @@ import openai
|
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
from langchain.memory import ConversationBufferMemory
|
9 |
from llm import generate_prompt, generate_conversation, predict
|
|
|
10 |
|
11 |
openai_api_key = os.environ['OPENAI_API_KEY']
|
12 |
openai.api_key = openai_api_key
|
@@ -19,7 +20,7 @@ def get_job_description_fixer_conversation():
|
|
19 |
prompt = generate_prompt(
|
20 |
input_variables=['history', 'input'],
|
21 |
template_file='templates/job_description_fixer.txt')
|
22 |
-
llm = ChatOpenAI(temperature=
|
23 |
memory = ConversationBufferMemory(ai_prefix="JobGPT")
|
24 |
conversation = generate_conversation(memory=memory, llm=llm, prompt=prompt)
|
25 |
return conversation
|
|
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
from langchain.memory import ConversationBufferMemory
|
9 |
from llm import generate_prompt, generate_conversation, predict
|
10 |
+
from constants import TEMPERATURE, MODEL_NAME
|
11 |
|
12 |
openai_api_key = os.environ['OPENAI_API_KEY']
|
13 |
openai.api_key = openai_api_key
|
|
|
20 |
prompt = generate_prompt(
|
21 |
input_variables=['history', 'input'],
|
22 |
template_file='templates/job_description_fixer.txt')
|
23 |
+
llm = ChatOpenAI(temperature=TEMPERATURE, openai_api_key=openai_api_key, model=MODEL_NAME)
|
24 |
memory = ConversationBufferMemory(ai_prefix="JobGPT")
|
25 |
conversation = generate_conversation(memory=memory, llm=llm, prompt=prompt)
|
26 |
return conversation
|
job_description_generator.py
CHANGED
@@ -7,7 +7,7 @@ import openai
|
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
from langchain.memory import ConversationBufferMemory
|
9 |
from llm import generate_prompt, generate_conversation, predict
|
10 |
-
|
11 |
openai_api_key = os.environ['OPENAI_API_KEY']
|
12 |
openai.api_key = openai_api_key
|
13 |
|
@@ -19,7 +19,7 @@ def get_job_description_conversation():
|
|
19 |
prompt = generate_prompt(
|
20 |
input_variables=['history', 'input'],
|
21 |
template_file='templates/job_description_generation.txt')
|
22 |
-
llm = ChatOpenAI(temperature=
|
23 |
memory = ConversationBufferMemory(ai_prefix="JobGPT")
|
24 |
conversation = generate_conversation(memory=memory, llm=llm, prompt=prompt)
|
25 |
return conversation
|
|
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
from langchain.memory import ConversationBufferMemory
|
9 |
from llm import generate_prompt, generate_conversation, predict
|
10 |
+
from constants import TEMPERATURE, MODEL_NAME
|
11 |
openai_api_key = os.environ['OPENAI_API_KEY']
|
12 |
openai.api_key = openai_api_key
|
13 |
|
|
|
19 |
prompt = generate_prompt(
|
20 |
input_variables=['history', 'input'],
|
21 |
template_file='templates/job_description_generation.txt')
|
22 |
+
llm = ChatOpenAI(temperature=TEMPERATURE, openai_api_key=openai_api_key, model=MODEL_NAME)
|
23 |
memory = ConversationBufferMemory(ai_prefix="JobGPT")
|
24 |
conversation = generate_conversation(memory=memory, llm=llm, prompt=prompt)
|
25 |
return conversation
|
loaders.py
CHANGED
@@ -3,12 +3,13 @@
|
|
3 |
'''
|
4 |
|
5 |
import os
|
6 |
-
from langchain.document_loaders import PyPDFLoader
|
7 |
from langchain.text_splitter import CharacterTextSplitter
|
8 |
from langchain.embeddings import OpenAIEmbeddings
|
9 |
from langchain.vectorstores import Chroma
|
10 |
from langchain.chains import RetrievalQA
|
11 |
from langchain.chat_models import ChatOpenAI
|
|
|
12 |
|
13 |
openai_api_key=os.environ['OPENAI_API_KEY']
|
14 |
|
@@ -19,12 +20,33 @@ def load_pdf(path: str = "resume.pdf"):
|
|
19 |
pdf_loader = PyPDFLoader(path)
|
20 |
documents = pdf_loader.load()
|
21 |
return documents
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
def get_embeddings(documents):
|
24 |
'''
|
25 |
Get embeddings from a list of documents
|
26 |
'''
|
27 |
-
splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=
|
28 |
texts = splitter.split_documents(documents)
|
29 |
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
|
30 |
return texts, embeddings
|
@@ -47,12 +69,12 @@ def get_chain_for_pdf(path):
|
|
47 |
'''
|
48 |
Get a conversation chain from a path
|
49 |
'''
|
50 |
-
documents =
|
51 |
texts, embeddings = get_embeddings(documents)
|
52 |
db = get_db(texts, embeddings)
|
53 |
retriever = get_retriever(db)
|
54 |
chain = RetrievalQA.from_chain_type(
|
55 |
-
llm=ChatOpenAI(temperature=
|
56 |
chain_type="stuff",
|
57 |
retriever=retriever,
|
58 |
return_source_documents=True)
|
|
|
3 |
'''
|
4 |
|
5 |
import os
|
6 |
+
from langchain.document_loaders import PyPDFLoader, Docx2txtLoader, TextLoader
|
7 |
from langchain.text_splitter import CharacterTextSplitter
|
8 |
from langchain.embeddings import OpenAIEmbeddings
|
9 |
from langchain.vectorstores import Chroma
|
10 |
from langchain.chains import RetrievalQA
|
11 |
from langchain.chat_models import ChatOpenAI
|
12 |
+
from constants import TEMPERATURE, MODEL_NAME
|
13 |
|
14 |
openai_api_key=os.environ['OPENAI_API_KEY']
|
15 |
|
|
|
20 |
pdf_loader = PyPDFLoader(path)
|
21 |
documents = pdf_loader.load()
|
22 |
return documents
|
23 |
+
|
24 |
+
def load_multiple_documents(path: str = "documents"):
|
25 |
+
'''
|
26 |
+
Load multiple documents from a folder
|
27 |
+
'''
|
28 |
+
documents = []
|
29 |
+
for file in os.listdir(path):
|
30 |
+
if file.endswith('.pdf'):
|
31 |
+
pdf_path = './documents/' + file
|
32 |
+
loader = PyPDFLoader(pdf_path)
|
33 |
+
documents.extend(loader.load())
|
34 |
+
elif file.endswith('.docx') or file.endswith('.doc'):
|
35 |
+
doc_path = './documents/' + file
|
36 |
+
loader = Docx2txtLoader(doc_path)
|
37 |
+
documents.extend(loader.load())
|
38 |
+
elif file.endswith('.txt'):
|
39 |
+
text_path = './documents/' + file
|
40 |
+
loader = TextLoader(text_path)
|
41 |
+
documents.extend(loader.load())
|
42 |
+
return documents
|
43 |
+
|
44 |
|
45 |
def get_embeddings(documents):
|
46 |
'''
|
47 |
Get embeddings from a list of documents
|
48 |
'''
|
49 |
+
splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=10)
|
50 |
texts = splitter.split_documents(documents)
|
51 |
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
|
52 |
return texts, embeddings
|
|
|
69 |
'''
|
70 |
Get a conversation chain from a path
|
71 |
'''
|
72 |
+
documents = load_multiple_documents(path)
|
73 |
texts, embeddings = get_embeddings(documents)
|
74 |
db = get_db(texts, embeddings)
|
75 |
retriever = get_retriever(db)
|
76 |
chain = RetrievalQA.from_chain_type(
|
77 |
+
llm=ChatOpenAI(temperature=TEMPERATURE, openai_api_key=openai_api_key, model=MODEL_NAME),
|
78 |
chain_type="stuff",
|
79 |
retriever=retriever,
|
80 |
return_source_documents=True)
|