AnishaG0201 commited on
Commit
06b2811
1 Parent(s): bd2cd64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -3
app.py CHANGED
@@ -160,12 +160,37 @@ def evaluate_answer(question, user_answer):
160
 
161
  # ----------------------
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
164
  def generate_report():
165
  st.write("### Interview Report")
166
  for i in range(st.session_state['total_questions']):
167
  st.write(f"**Question {i+1}:** {st.session_state['questions'][i]}")
168
  st.write(f"**Your Answer:** {st.session_state['answers'][i]}")
 
169
  st.write(f"**Feedback:** {st.session_state['feedback'][i]}")
170
  st.write("---")
171
 
@@ -176,6 +201,8 @@ if 'answers' not in st.session_state:
176
  st.session_state['answers'] = []
177
  if 'feedback' not in st.session_state:
178
  st.session_state['feedback'] = []
 
 
179
  if 'current_question' not in st.session_state:
180
  st.session_state['current_question'] = 0
181
  if 'total_questions' not in st.session_state:
@@ -188,8 +215,38 @@ if 'interview_started' not in st.session_state:
188
  st.title("Mock Interview Bot")
189
 
190
  if not st.session_state['interview_started']:
191
- role = st.selectbox("Select the role:", ["Software Engineer", "Data Scientist", "Product Manager"])
192
- topic = st.text_input("Enter the topic:")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  difficulty_level = st.selectbox("Select difficulty level:", ["Easy", "Medium", "Hard"])
194
 
195
  if st.button("Start Interview"):
@@ -209,9 +266,11 @@ if st.session_state['interview_started']:
209
  if st.button("Submit Answer"):
210
  if answer:
211
  st.session_state['answers'].append(answer)
212
- feedback = evaluate_answer(st.session_state['questions'][current_question], answer)
 
213
  st.session_state['feedback'].append(feedback)
214
  st.session_state['question_answered'] = True
 
215
  st.write(f"Feedback: {feedback}")
216
 
217
  if st.session_state['question_answered']:
 
160
 
161
  # ----------------------
162
 
163
+ import openai
164
+ import streamlit as st
165
+
166
+ # Set your OpenAI API key
167
+ openai.api_key = "YOUR_OPENAI_API_KEY"
168
+
169
+ def generate_question(role, topic, difficulty_level):
170
+ prompt = f"Generate an interview question for the role of {role} on the topic of {topic} with difficulty level {difficulty_level}."
171
+ llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
172
+ response = llm.invoke(prompt)
173
+ response = response.content
174
+
175
+ return response
176
+
177
+ def evaluate_answer(question, user_answer):
178
+ prompt = f"Question: {question}\nUser's Answer: {user_answer}\nEvaluate the answer, give a score out of 100, and provide feedback. Also, provide the best possible answer."
179
+ llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
180
+ response = llm.invoke(prompt)
181
+
182
+ evaluation = response.content
183
+ # Extract score and feedback from the evaluation
184
+ score_line, feedback = evaluation.split('\n', 1)
185
+ score = int(score_line.split()[-1])
186
+ return score, feedback
187
 
188
  def generate_report():
189
  st.write("### Interview Report")
190
  for i in range(st.session_state['total_questions']):
191
  st.write(f"**Question {i+1}:** {st.session_state['questions'][i]}")
192
  st.write(f"**Your Answer:** {st.session_state['answers'][i]}")
193
+ st.write(f"**Score:** {st.session_state['scores'][i]}")
194
  st.write(f"**Feedback:** {st.session_state['feedback'][i]}")
195
  st.write("---")
196
 
 
201
  st.session_state['answers'] = []
202
  if 'feedback' not in st.session_state:
203
  st.session_state['feedback'] = []
204
+ if 'scores' not in st.session_state:
205
+ st.session_state['scores'] = []
206
  if 'current_question' not in st.session_state:
207
  st.session_state['current_question'] = 0
208
  if 'total_questions' not in st.session_state:
 
215
  st.title("Mock Interview Bot")
216
 
217
  if not st.session_state['interview_started']:
218
+ roles_and_topics = {
219
+
220
+ "Front-End Developer": ["HTML/CSS", "JavaScript and Frameworks (React, Angular, Vue.js)", "Responsive Design", "Browser Compatibility"],
221
+ "Back-End Developer": ["Server-Side Languages (Node.js, Python, Ruby, PHP)", "Database Management (SQL, NoSQL)", "API Development", "Server and Hosting Management"],
222
+ "Full-Stack Developer": ["Combination of Front-End and Back-End Topics", "Integration of Systems", "DevOps Basics"],
223
+ "Mobile Developer": ["Android Development (Java, Kotlin)", "iOS Development (Swift, Objective-C)", "Cross-Platform Development (Flutter, React Native)"],
224
+ "Data Scientist": ["Statistical Analysis", "Machine Learning Algorithms", "Data Wrangling and Cleaning", "Data Visualization"],
225
+ "Data Analyst": ["Data Collection and Processing", "SQL and Database Querying", "Data Visualization Tools (Tableau, Power BI)", "Basic Statistics"],
226
+ "Machine Learning Engineer": ["Supervised and Unsupervised Learning", "Model Deployment", "Deep Learning", "Natural Language Processing"],
227
+ "DevOps Engineer": ["Continuous Integration/Continuous Deployment (CI/CD)", "Containerization (Docker, Kubernetes)", "Infrastructure as Code (Terraform, Ansible)", "Cloud Platforms (AWS, Azure, Google Cloud)"],
228
+ "Cloud Engineer": ["Cloud Architecture", "Cloud Services (Compute, Storage, Networking)", "Security in the Cloud", "Cost Management"],
229
+ "Cybersecurity Analyst": ["Threat Detection and Mitigation", "Security Protocols and Encryption", "Network Security", "Incident Response"],
230
+ "Penetration Tester": ["Vulnerability Assessment", "Ethical Hacking Techniques", "Security Tools (Metasploit, Burp Suite)", "Report Writing and Documentation"],
231
+ "Project Manager": ["Project Planning and Scheduling", "Risk Management", "Agile and Scrum Methodologies", "Stakeholder Communication"],
232
+ "UX/UI Designer": ["User Research", "Wireframing and Prototyping", "Design Principles", "Usability Testing"],
233
+ "Quality Assurance (QA) Engineer": ["Testing Methodologies", "Automation Testing", "Bug Tracking", "Performance Testing"],
234
+ "Blockchain Developer": ["Blockchain Fundamentals", "Smart Contracts", "Cryptographic Algorithms", "Decentralized Applications (DApps)"],
235
+ "Digital Marketing Specialist": ["SEO/SEM", "Social Media Marketing", "Content Marketing", "Analytics and Reporting"],
236
+ "AI Research Scientist": ["AI Theory", "Algorithm Development", "Neural Networks", "Natural Language Processing"],
237
+ "AI Engineer": ["AI Model Deployment", "Machine Learning Engineering", "Deep Learning", "AI Tools and Frameworks"],
238
+ "Generative AI Specialist (GenAI)": ["Generative Models", "GANs (Generative Adversarial Networks)", "Creative AI Applications", "Ethics in AI"],
239
+ "Generative Business Intelligence Specialist (GenBI)": ["Automated Data Analysis", "Business Intelligence Tools", "Predictive Analytics", "AI in Business Strategy"]
240
+
241
+
242
+ }
243
+
244
+
245
+
246
+
247
+
248
+ role = st.selectbox('Select Role', list(roles_and_topics.keys()))
249
+ topic = st.selectbox('Select Topic', roles_and_topics[selected_topic_level])
250
  difficulty_level = st.selectbox("Select difficulty level:", ["Easy", "Medium", "Hard"])
251
 
252
  if st.button("Start Interview"):
 
266
  if st.button("Submit Answer"):
267
  if answer:
268
  st.session_state['answers'].append(answer)
269
+ score, feedback = evaluate_answer(st.session_state['questions'][current_question], answer)
270
+ st.session_state['scores'].append(score)
271
  st.session_state['feedback'].append(feedback)
272
  st.session_state['question_answered'] = True
273
+ st.write(f"Score: {score}")
274
  st.write(f"Feedback: {feedback}")
275
 
276
  if st.session_state['question_answered']: