AdamyaG commited on
Commit
7dcb3cd
·
verified ·
1 Parent(s): 3c55929

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +139 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain_google_genai import ChatGoogleGenerativeAI
3
+ import re
4
+
5
+ def generate_question(role, topic, difficulty_level):
6
+ prompt = f"Generate an interview question for the role of {role} on the topic of {topic} with difficulty level {difficulty_level}."
7
+ llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
8
+ response = llm.invoke(prompt)
9
+ response = response.content
10
+
11
+ return response
12
+
13
+ def evaluate_answer(question, user_answer):
14
+ prompt = f"Question: {question}\nUser's Answer: {user_answer}\nEvaluate the answer and provide feedback. Also, provide the best possible answer."
15
+ llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
16
+ response = llm.invoke(prompt)
17
+ response = response.content
18
+
19
+ return response
20
+
21
+ # ----------------------
22
+ def generate_question(role, topic, difficulty_level):
23
+ prompt = f"Generate an interview question for the role of {role} on the topic of {topic} with difficulty level {difficulty_level}."
24
+ llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
25
+ response = llm.invoke(prompt)
26
+ response = response.content
27
+
28
+ return response
29
+
30
+ def evaluate_answer(question, user_answer):
31
+ 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."
32
+ llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
33
+ response = llm.invoke(prompt)
34
+
35
+ evaluation = response.content
36
+ # Extract score and feedback from the evaluation
37
+ # Extract score using regular expressions
38
+ score_match = re.search(r'(\d+)/100', evaluation)
39
+ score = int(score_match.group(1)) if score_match else 0
40
+
41
+ # Extract feedback
42
+ feedback = evaluation.split('\n', 1)[1] if '\n' in evaluation else evaluation
43
+ return score, feedback
44
+
45
+ def generate_report():
46
+ st.write("### Interview Report")
47
+ for i in range(st.session_state['total_questions']):
48
+ st.write(f"**Question {i+1}:** {st.session_state['questions'][i]}")
49
+ st.write(f"**Your Answer:** {st.session_state['answers'][i]}")
50
+ st.write(f"**Score:** {st.session_state['scores'][i]}")
51
+ st.write(f"**Feedback:** {st.session_state['feedback'][i]}")
52
+ st.write("---")
53
+
54
+ # Initialize session state
55
+ if 'questions' not in st.session_state:
56
+ st.session_state['questions'] = []
57
+ if 'answers' not in st.session_state:
58
+ st.session_state['answers'] = []
59
+ if 'feedback' not in st.session_state:
60
+ st.session_state['feedback'] = []
61
+ if 'scores' not in st.session_state:
62
+ st.session_state['scores'] = []
63
+ if 'current_question' not in st.session_state:
64
+ st.session_state['current_question'] = 0
65
+ if 'total_questions' not in st.session_state:
66
+ st.session_state['total_questions'] = 10
67
+ if 'question_answered' not in st.session_state:
68
+ st.session_state['question_answered'] = False
69
+ if 'interview_started' not in st.session_state:
70
+ st.session_state['interview_started'] = False
71
+
72
+ st.title("Mock Interview Bot")
73
+
74
+ if not st.session_state['interview_started']:
75
+ roles_and_topics = {
76
+
77
+ "Front-End Developer": ["HTML/CSS", "JavaScript and Frameworks (React, Angular, Vue.js)", "Responsive Design", "Browser Compatibility"],
78
+ "Back-End Developer": ["Server-Side Languages (Node.js, Python, Ruby, PHP)", "Database Management (SQL, NoSQL)", "API Development", "Server and Hosting Management"],
79
+ "Full-Stack Developer": ["Combination of Front-End and Back-End Topics", "Integration of Systems", "DevOps Basics"],
80
+ "Mobile Developer": ["Android Development (Java, Kotlin)", "iOS Development (Swift, Objective-C)", "Cross-Platform Development (Flutter, React Native)"],
81
+ "Data Scientist": ["Statistical Analysis", "Machine Learning Algorithms", "Data Wrangling and Cleaning", "Data Visualization"],
82
+ "Data Analyst": ["Data Collection and Processing", "SQL and Database Querying", "Data Visualization Tools (Tableau, Power BI)", "Basic Statistics"],
83
+ "Machine Learning Engineer": ["Supervised and Unsupervised Learning", "Model Deployment", "Deep Learning", "Natural Language Processing"],
84
+ "DevOps Engineer": ["Continuous Integration/Continuous Deployment (CI/CD)", "Containerization (Docker, Kubernetes)", "Infrastructure as Code (Terraform, Ansible)", "Cloud Platforms (AWS, Azure, Google Cloud)"],
85
+ "Cloud Engineer": ["Cloud Architecture", "Cloud Services (Compute, Storage, Networking)", "Security in the Cloud", "Cost Management"],
86
+ "Cybersecurity Analyst": ["Threat Detection and Mitigation", "Security Protocols and Encryption", "Network Security", "Incident Response"],
87
+ "Penetration Tester": ["Vulnerability Assessment", "Ethical Hacking Techniques", "Security Tools (Metasploit, Burp Suite)", "Report Writing and Documentation"],
88
+ "Project Manager": ["Project Planning and Scheduling", "Risk Management", "Agile and Scrum Methodologies", "Stakeholder Communication"],
89
+ "UX/UI Designer": ["User Research", "Wireframing and Prototyping", "Design Principles", "Usability Testing"],
90
+ "Quality Assurance (QA) Engineer": ["Testing Methodologies", "Automation Testing", "Bug Tracking", "Performance Testing"],
91
+ "Blockchain Developer": ["Blockchain Fundamentals", "Smart Contracts", "Cryptographic Algorithms", "Decentralized Applications (DApps)"],
92
+ "Digital Marketing Specialist": ["SEO/SEM", "Social Media Marketing", "Content Marketing", "Analytics and Reporting"],
93
+ "AI Research Scientist": ["AI Theory", "Algorithm Development", "Neural Networks", "Natural Language Processing"],
94
+ "AI Engineer": ["AI Model Deployment", "Machine Learning Engineering", "Deep Learning", "AI Tools and Frameworks"],
95
+ "Generative AI Specialist (GenAI)": ["Generative Models", "GANs (Generative Adversarial Networks)", "Creative AI Applications", "Ethics in AI"],
96
+ "Generative Business Intelligence Specialist (GenBI)": ["Automated Data Analysis", "Business Intelligence Tools", "Predictive Analytics", "AI in Business Strategy"]
97
+
98
+
99
+ }
100
+
101
+
102
+
103
+
104
+
105
+ role = st.selectbox('Select Role', list(roles_and_topics.keys()))
106
+ topic = st.selectbox('Select Topic', roles_and_topics[role])
107
+ difficulty_level = st.selectbox("Select difficulty level:", ["Easy", "Medium", "Hard"])
108
+
109
+ if st.button("Start Interview"):
110
+ if role and topic and difficulty_level:
111
+ st.session_state['questions'] = [generate_question(role, topic, difficulty_level) for _ in range(st.session_state['total_questions'])]
112
+ st.session_state['current_question'] = 0
113
+ st.session_state['interview_started'] = True
114
+ st.session_state['question_answered'] = False
115
+
116
+ if st.session_state['interview_started']:
117
+ current_question = st.session_state['current_question']
118
+ if current_question < st.session_state['total_questions']:
119
+ st.write(f"Question {current_question + 1}: {st.session_state['questions'][current_question]}")
120
+
121
+ if not st.session_state['question_answered']:
122
+ answer = st.text_area("Your Answer:", key=f"answer_{current_question}")
123
+ if st.button("Submit Answer"):
124
+ if answer:
125
+ st.session_state['answers'].append(answer)
126
+ score, feedback = evaluate_answer(st.session_state['questions'][current_question], answer)
127
+ st.session_state['scores'].append(score)
128
+ st.session_state['feedback'].append(feedback)
129
+ st.session_state['question_answered'] = True
130
+ st.write(f"Score: {score}")
131
+ st.write(f"Feedback: {feedback}")
132
+
133
+ if st.session_state['question_answered']:
134
+ if st.button("Next Question"):
135
+ st.session_state['current_question'] += 1
136
+ st.session_state['question_answered'] = False
137
+ else:
138
+ st.write("Interview Complete! Generating Report...")
139
+ generate_report()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ langchain_community
3
+ requests
4
+ langchain_Google_Genai