Aditya Patkar commited on
Commit
c96c102
1 Parent(s): 92dff8b

Added interview questions generator chatbot

Browse files
app.py CHANGED
@@ -8,6 +8,8 @@ from streamlit_chat import message
8
 
9
  from job_description_generator import predict_job_description, get_job_description_conversation
10
  from job_description_fixer import fix_job_description, get_job_description_fixer_conversation
 
 
11
  from cover_letter_generator import get_cover_letter
12
 
13
  conversation = get_job_description_conversation()
@@ -17,6 +19,10 @@ if 'generator_conversation' not in st.session_state:
17
  fixer_conversation = get_job_description_fixer_conversation()
18
  if 'fixer_conversation' not in st.session_state:
19
  st.session_state['fixer_conversation'] = fixer_conversation
 
 
 
 
20
 
21
  def message_writer(input_text, response):
22
  '''
@@ -69,7 +75,11 @@ def main():
69
  st.sidebar.markdown("---")
70
  #selector
71
  page = st.sidebar.selectbox(
72
- "Select a page", ["Home", "Job Description Generator", "Job Description Fixer", "Cover Letter Generator"])
 
 
 
 
73
  if page == "Home":
74
  st.title("JobGPT")
75
  st.write("Select a page in the sidebar to get started.")
@@ -77,6 +87,7 @@ def main():
77
  st.write("1. Job Description Generator")
78
  st.write("2. Job Description Fixer")
79
  st.write("3. Cover Letter Generator")
 
80
  st.markdown("---")
81
 
82
  elif page == "Job Description Generator":
@@ -143,19 +154,15 @@ def main():
143
  container_three.markdown( "JobGPT is a chatbot that generates cover letters. \
144
  This is built just for demo purpose.")
145
  container_three.markdown("---")
146
- #upload file
147
  uploaded_file = container_three.file_uploader("Upload your resume", type=["pdf"])
148
  if uploaded_file is not None:
149
- #store it as a pdf
150
  with open("resume.pdf", "wb") as file_io:
151
  file_io.write(uploaded_file.getbuffer())
152
-
153
- #show a loading bar
154
  with st.spinner('Uploading...'):
155
  time.sleep(1)
156
  container_three.success('Uploaded!')
157
  container_three.markdown("---")
158
- #add a form to get title, company and more info from the user
159
  form = container_three.form(key='my_form')
160
  title = form.text_input("Job Title (required)", placeholder="VP of Engineering")
161
  company = form.text_input("Company Name (required)", placeholder="Google")
@@ -175,4 +182,34 @@ def main():
175
  container_three.markdown("### Cover Letter:")
176
  container_three.write(cover_letter)
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  main()
 
8
 
9
  from job_description_generator import predict_job_description, get_job_description_conversation
10
  from job_description_fixer import fix_job_description, get_job_description_fixer_conversation
11
+ from interview_questions_generator import (predict_interview_question,
12
+ get_interview_questions_conversation)
13
  from cover_letter_generator import get_cover_letter
14
 
15
  conversation = get_job_description_conversation()
 
19
  fixer_conversation = get_job_description_fixer_conversation()
20
  if 'fixer_conversation' not in st.session_state:
21
  st.session_state['fixer_conversation'] = fixer_conversation
22
+
23
+ interview_questions_conversation = get_interview_questions_conversation()
24
+ if 'interview_questions_conversation' not in st.session_state:
25
+ st.session_state['interview_questions_conversation'] = interview_questions_conversation
26
 
27
  def message_writer(input_text, response):
28
  '''
 
75
  st.sidebar.markdown("---")
76
  #selector
77
  page = st.sidebar.selectbox(
78
+ "Select a page", ["Home",
79
+ "Job Description Generator",
80
+ "Job Description Fixer",
81
+ "Cover Letter Generator",
82
+ "interview questions generator"])
83
  if page == "Home":
84
  st.title("JobGPT")
85
  st.write("Select a page in the sidebar to get started.")
 
87
  st.write("1. Job Description Generator")
88
  st.write("2. Job Description Fixer")
89
  st.write("3. Cover Letter Generator")
90
+ st.write("4. Interview Questions Generator")
91
  st.markdown("---")
92
 
93
  elif page == "Job Description Generator":
 
154
  container_three.markdown( "JobGPT is a chatbot that generates cover letters. \
155
  This is built just for demo purpose.")
156
  container_three.markdown("---")
 
157
  uploaded_file = container_three.file_uploader("Upload your resume", type=["pdf"])
158
  if uploaded_file is not None:
 
159
  with open("resume.pdf", "wb") as file_io:
160
  file_io.write(uploaded_file.getbuffer())
161
+
 
162
  with st.spinner('Uploading...'):
163
  time.sleep(1)
164
  container_three.success('Uploaded!')
165
  container_three.markdown("---")
 
166
  form = container_three.form(key='my_form')
167
  title = form.text_input("Job Title (required)", placeholder="VP of Engineering")
168
  company = form.text_input("Company Name (required)", placeholder="Google")
 
182
  container_three.markdown("### Cover Letter:")
183
  container_three.write(cover_letter)
184
 
185
+ elif page == "interview questions generator":
186
+ container_two = st.container()
187
+ container_two.title("A Interview Questions Generating Chatbot")
188
+ container_two.markdown(
189
+ "JobGPT is a chatbot that generates interview questions.\
190
+ This is built just for demo purpose."
191
+ )
192
+ input_text = container_two.text_area(
193
+ "Prompt",
194
+ "Hi, can you please help me generate interview questions?")
195
+ button = container_two.button("Send")
196
+
197
+ st.sidebar.markdown("---")
198
+ st.sidebar.markdown("Click on `new chat` to start a new chat. \
199
+ History will be cleared and you'll lose access to current chat."
200
+ )
201
+ clear_session = st.sidebar.button("New Chat")
202
+
203
+ if clear_session:
204
+ st.session_state['interview_questions_conversation'] = interview_questions_conversation
205
+ container_two.markdown("---")
206
+
207
+ initial_message = "Hello, how can I help you?"
208
+ message(initial_message)
209
+
210
+ if button:
211
+ response = predict_interview_question(
212
+ input_text, st.session_state['interview_questions_conversation'])
213
+ message_writer(input_text, response)
214
+
215
  main()
interview_questions_generator.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ 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
9
+
10
+
11
+ def get_interview_questions_conversation():
12
+ '''
13
+ Generate a conversation object for job description generation
14
+ '''
15
+ prompt = generate_prompt(
16
+ input_variables=['history', 'input'],
17
+ template_file='templates/interview_question_generator.txt')
18
+ llm = ChatOpenAI(temperature=0, openai_api_key=openai_api_key)
19
+ memory = ConversationBufferMemory(ai_prefix="JobGPT")
20
+ conversation = generate_conversation(memory=memory, llm=llm, prompt=prompt)
21
+ return conversation
22
+
23
+
24
+ def predict_interview_question(input_text: str, conversation: object):
25
+ '''
26
+ Predict the next response from the conversation object
27
+ '''
28
+ response = predict(input_text=input_text, conversation=conversation)
29
+ return response
templates/interview_question_generator.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ JobGPT is a friendly and professional chatbot bot that generates interview questions based on the job description of executive positions that is given to it. \
2
+
3
+ It should get following information from the user, asking only one question at a time to not overwhelm the user: \
4
+ 1. Number of questions to be generated. \
5
+ 2. Type of questions (Technical, Behavioral, etc.) \
6
+ 3, Job description of the position. \
7
+
8
+ It should strictly follow following guidelines: \
9
+ 1. The questions should be open-ended. \
10
+ 2. The questions should test the candidate for the skills and requirements mentioned in the job description. \
11
+ 3. The questions should be well-suited for the level of job description given. \
12
+
13
+ Once it has the questions and answers, it returns them as a well formatted markdown text. \
14
+
15
+ The following is a friendly conversation between a human and JobGPT. JobGPT provides lots of specific details from its context. Your job is to predict what JobGPT says next.
16
+
17
+ Current conversation:
18
+ {history}
19
+ Human: {input}
20
+ JobGPT: