Update app.py
Browse files
app.py
CHANGED
@@ -1,121 +1,121 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from function import GetLLMResponse
|
3 |
|
4 |
-
from langchain_community.llms import OpenAI
|
5 |
-
from langchain_google_genai import ChatGoogleGenerativeAI
|
6 |
|
7 |
|
8 |
-
# Page configuration
|
9 |
-
st.set_page_config(page_title="Interview Practice Bot",
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
-
def main():
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
45 |
|
46 |
-
|
47 |
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
|
53 |
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
|
95 |
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
|
105 |
-
|
106 |
|
107 |
-
|
108 |
-
|
109 |
|
110 |
-
|
111 |
|
112 |
|
113 |
|
114 |
-
|
115 |
-
|
116 |
|
117 |
-
|
118 |
-
|
119 |
|
120 |
|
121 |
|
@@ -125,5 +125,59 @@ def main():
|
|
125 |
|
126 |
|
127 |
|
128 |
-
if __name__ == "__main__":
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import streamlit as st
|
2 |
+
# from function import GetLLMResponse
|
3 |
|
4 |
+
# from langchain_community.llms import OpenAI
|
5 |
+
# from langchain_google_genai import ChatGoogleGenerativeAI
|
6 |
|
7 |
|
8 |
+
# # Page configuration
|
9 |
+
# st.set_page_config(page_title="Interview Practice Bot",
|
10 |
+
# page_icon="๐",
|
11 |
+
# layout="wide",
|
12 |
+
# initial_sidebar_state="collapsed")
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
+
# def main():
|
18 |
+
# roles_and_topics = {
|
19 |
|
20 |
+
# "Front-End Developer": ["HTML/CSS", "JavaScript and Frameworks (React, Angular, Vue.js)", "Responsive Design", "Browser Compatibility"],
|
21 |
+
# "Back-End Developer": ["Server-Side Languages (Node.js, Python, Ruby, PHP)", "Database Management (SQL, NoSQL)", "API Development", "Server and Hosting Management"],
|
22 |
+
# "Full-Stack Developer": ["Combination of Front-End and Back-End Topics", "Integration of Systems", "DevOps Basics"],
|
23 |
+
# "Mobile Developer": ["Android Development (Java, Kotlin)", "iOS Development (Swift, Objective-C)", "Cross-Platform Development (Flutter, React Native)"],
|
24 |
+
# "Data Scientist": ["Statistical Analysis", "Machine Learning Algorithms", "Data Wrangling and Cleaning", "Data Visualization"],
|
25 |
+
# "Data Analyst": ["Data Collection and Processing", "SQL and Database Querying", "Data Visualization Tools (Tableau, Power BI)", "Basic Statistics"],
|
26 |
+
# "Machine Learning Engineer": ["Supervised and Unsupervised Learning", "Model Deployment", "Deep Learning", "Natural Language Processing"],
|
27 |
+
# "DevOps Engineer": ["Continuous Integration/Continuous Deployment (CI/CD)", "Containerization (Docker, Kubernetes)", "Infrastructure as Code (Terraform, Ansible)", "Cloud Platforms (AWS, Azure, Google Cloud)"],
|
28 |
+
# "Cloud Engineer": ["Cloud Architecture", "Cloud Services (Compute, Storage, Networking)", "Security in the Cloud", "Cost Management"],
|
29 |
+
# "Cybersecurity Analyst": ["Threat Detection and Mitigation", "Security Protocols and Encryption", "Network Security", "Incident Response"],
|
30 |
+
# "Penetration Tester": ["Vulnerability Assessment", "Ethical Hacking Techniques", "Security Tools (Metasploit, Burp Suite)", "Report Writing and Documentation"],
|
31 |
+
# "Project Manager": ["Project Planning and Scheduling", "Risk Management", "Agile and Scrum Methodologies", "Stakeholder Communication"],
|
32 |
+
# "UX/UI Designer": ["User Research", "Wireframing and Prototyping", "Design Principles", "Usability Testing"],
|
33 |
+
# "Quality Assurance (QA) Engineer": ["Testing Methodologies", "Automation Testing", "Bug Tracking", "Performance Testing"],
|
34 |
+
# "Blockchain Developer": ["Blockchain Fundamentals", "Smart Contracts", "Cryptographic Algorithms", "Decentralized Applications (DApps)"],
|
35 |
+
# "Digital Marketing Specialist": ["SEO/SEM", "Social Media Marketing", "Content Marketing", "Analytics and Reporting"],
|
36 |
+
# "AI Research Scientist": ["AI Theory", "Algorithm Development", "Neural Networks", "Natural Language Processing"],
|
37 |
+
# "AI Engineer": ["AI Model Deployment", "Machine Learning Engineering", "Deep Learning", "AI Tools and Frameworks"],
|
38 |
+
# "Generative AI Specialist (GenAI)": ["Generative Models", "GANs (Generative Adversarial Networks)", "Creative AI Applications", "Ethics in AI"],
|
39 |
+
# "Generative Business Intelligence Specialist (GenBI)": ["Automated Data Analysis", "Business Intelligence Tools", "Predictive Analytics", "AI in Business Strategy"]
|
40 |
|
41 |
|
42 |
+
# }
|
43 |
|
44 |
+
# levels = ['Beginner','Intermediate','Advanced']
|
45 |
|
46 |
+
# Question_Difficulty = ['Easy','Medium','Hard']
|
47 |
|
48 |
|
49 |
+
# st.header("Select AI:")
|
50 |
+
# model = st.radio("Model", [ "Gemini","Open AI",])
|
51 |
+
# st.write("Selected option:", model)
|
52 |
|
53 |
|
54 |
|
55 |
+
# # Header and description
|
56 |
+
# st.title("Interview Practice Bot ๐")
|
57 |
+
# st.text("Choose the role and topic for your Interview.")
|
58 |
|
59 |
+
# # User input for quiz generation
|
60 |
+
# ## Layout in columns
|
61 |
+
# col4, col1, col2 = st.columns([1, 1, 1])
|
62 |
+
# col5, col3 = st.columns([1, 1])
|
63 |
|
64 |
|
65 |
+
# with col4:
|
66 |
+
# selected_level = st.selectbox('Select level of understanding', levels)
|
67 |
|
68 |
+
# with col1:
|
69 |
+
# selected_topic_level = st.selectbox('Select Role', list(roles_and_topics.keys()))
|
70 |
|
71 |
+
# with col2:
|
72 |
+
# selected_topic = st.selectbox('Select Topic', roles_and_topics[selected_topic_level])
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
+
# with col5:
|
79 |
+
# selected_Question_Difficulty = st.selectbox('Select Question Difficulty', Question_Difficulty)
|
80 |
|
81 |
+
# with col3:
|
82 |
+
# num_quizzes = st.slider('Number of Questions', min_value=1, max_value= 10, value=1)
|
83 |
|
84 |
+
# submit = st.button('Generate Questions')
|
85 |
+
# st.write(selected_topic_level, selected_topic, num_quizzes, selected_Question_Difficulty, selected_level, model)
|
86 |
|
87 |
+
# # Final Response
|
88 |
+
# if submit:
|
89 |
+
# questions,answers = GetLLMResponse(selected_topic_level, selected_topic, num_quizzes, selected_Question_Difficulty, selected_level, model)
|
90 |
|
91 |
+
# with st.spinner("Generating Quizzes..."):
|
92 |
+
# questions,answers = GetLLMResponse(selected_topic_level, selected_topic, num_quizzes, selected_Question_Difficulty, selected_level, model)
|
93 |
+
# st.success("Quizzes Generated!")
|
94 |
|
95 |
|
96 |
|
97 |
+
# # Display questions and answers in a table
|
98 |
+
# if questions:
|
99 |
+
# st.subheader("Quiz Questions and Answers:")
|
100 |
+
# # Prepare data for the table
|
101 |
+
# col1, col2 = st.columns(2)
|
102 |
+
# with col1:
|
103 |
+
# st.subheader("Questions")
|
104 |
|
105 |
+
# st.write(questions)
|
106 |
|
107 |
+
# with col2:
|
108 |
+
# st.subheader("Answers")
|
109 |
|
110 |
+
# st.write(answers)
|
111 |
|
112 |
|
113 |
|
114 |
+
# else:
|
115 |
+
# st.warning("No Quiz Questions and Answers")
|
116 |
|
117 |
+
# else:
|
118 |
+
# st.warning("Click the 'Generate Quizzes' button to create quizzes.")
|
119 |
|
120 |
|
121 |
|
|
|
125 |
|
126 |
|
127 |
|
128 |
+
# if __name__ == "__main__":
|
129 |
+
# main()
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
import openai
|
137 |
+
import streamlit as st
|
138 |
+
|
139 |
+
# Set your OpenAI API key
|
140 |
+
openai.api_key = "YOUR_OPENAI_API_KEY"
|
141 |
+
|
142 |
+
def generate_question(role, topic, difficulty_level):
|
143 |
+
prompt = f"Generate an interview question for the role of {role} on the topic of {topic} with difficulty level {difficulty_level}."
|
144 |
+
response = openai.Completion.create(
|
145 |
+
engine="text-davinci-003", # or any other engine you prefer
|
146 |
+
prompt=prompt,
|
147 |
+
max_tokens=50
|
148 |
+
)
|
149 |
+
return response.choices[0].text.strip()
|
150 |
+
|
151 |
+
def evaluate_answer(question, user_answer):
|
152 |
+
prompt = f"Question: {question}\nUser's Answer: {user_answer}\nEvaluate the answer and provide feedback. Also, provide the best possible answer."
|
153 |
+
response = openai.Completion.create(
|
154 |
+
engine="text-davinci-003",
|
155 |
+
prompt=prompt,
|
156 |
+
max_tokens=150
|
157 |
+
)
|
158 |
+
return response.choices[0].text.strip()
|
159 |
+
|
160 |
+
st.title("Mock Interview Bot")
|
161 |
+
|
162 |
+
role = st.selectbox("Select the role:", ["Software Engineer", "Data Scientist", "Product Manager"])
|
163 |
+
topic = st.text_input("Enter the topic:")
|
164 |
+
difficulty_level = st.selectbox("Select difficulty level:", ["Easy", "Medium", "Hard"])
|
165 |
+
|
166 |
+
if st.button("Generate Question"):
|
167 |
+
if role and topic and difficulty_level:
|
168 |
+
question = generate_question(role, topic, difficulty_level)
|
169 |
+
st.session_state['current_question'] = question
|
170 |
+
st.write(f"Question: {question}")
|
171 |
+
st.session_state['question_answered'] = False
|
172 |
+
|
173 |
+
if 'current_question' in st.session_state and not st.session_state.get('question_answered', False):
|
174 |
+
answer = st.text_area("Your Answer:")
|
175 |
+
if st.button("Submit Answer"):
|
176 |
+
if answer:
|
177 |
+
st.session_state['user_answer'] = answer
|
178 |
+
st.session_state['question_answered'] = True
|
179 |
+
|
180 |
+
if 'user_answer' in st.session_state:
|
181 |
+
with st.spinner("Evaluating your answer..."):
|
182 |
+
feedback = evaluate_answer(st.session_state['current_question'], st.session_state['user_answer'])
|
183 |
+
st.write(f"Feedback and Best Answer:\n{feedback}")
|