Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ load_dotenv()
|
|
| 9 |
# Configure Streamlit page settings
|
| 10 |
st.set_page_config(
|
| 11 |
page_title="Interview Prep Assistant",
|
| 12 |
-
page_icon="
|
| 13 |
layout="wide",
|
| 14 |
)
|
| 15 |
|
|
@@ -17,28 +17,33 @@ st.set_page_config(
|
|
| 17 |
st.markdown(
|
| 18 |
"""
|
| 19 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
body {
|
| 21 |
-
background-color: #
|
| 22 |
}
|
| 23 |
.stTabs [data-baseweb="tab-list"] {
|
| 24 |
justify-content: center;
|
| 25 |
}
|
| 26 |
.stTabs [data-baseweb="tab"] {
|
|
|
|
|
|
|
| 27 |
font-weight: bold;
|
| 28 |
-
color: black
|
| 29 |
-
|
| 30 |
-
border-radius: 20px; /* Oval Shape */
|
| 31 |
-
padding: 10px 20px;
|
| 32 |
-
margin: 5px;
|
| 33 |
}
|
| 34 |
-
.stTabs [aria-selected="true"] {
|
| 35 |
-
background-color: #
|
| 36 |
-
color: white
|
|
|
|
| 37 |
}
|
| 38 |
-
|
| 39 |
-
color: #
|
| 40 |
-
font-size: 32px;
|
| 41 |
-
font-weight: bold;
|
| 42 |
}
|
| 43 |
</style>
|
| 44 |
""",
|
|
@@ -49,7 +54,7 @@ st.markdown(
|
|
| 49 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 50 |
|
| 51 |
if not GOOGLE_API_KEY:
|
| 52 |
-
st.error("API key not found! Please set the GOOGLE_API_KEY in your .env file.")
|
| 53 |
st.stop()
|
| 54 |
|
| 55 |
# Configure the Generative AI model
|
|
@@ -57,7 +62,7 @@ try:
|
|
| 57 |
gen_ai.configure(api_key=GOOGLE_API_KEY)
|
| 58 |
model = gen_ai.GenerativeModel("gemini-pro")
|
| 59 |
except Exception as e:
|
| 60 |
-
st.error(f"Error initializing the Gemini-Pro model: {e}")
|
| 61 |
st.stop()
|
| 62 |
|
| 63 |
# Initialize the chat session
|
|
@@ -65,52 +70,52 @@ if "chat_session" not in st.session_state:
|
|
| 65 |
try:
|
| 66 |
st.session_state.chat_session = model.start_chat(history=[])
|
| 67 |
except Exception as e:
|
| 68 |
-
st.error(f"Error initializing chat session: {e}")
|
| 69 |
st.stop()
|
| 70 |
|
| 71 |
# Display chatbot title
|
| 72 |
st.title("🎯 Interview Prep Assistant")
|
| 73 |
|
| 74 |
# Tabs for category selection
|
| 75 |
-
tabs = ["💻 Technical", "
|
| 76 |
selected_tab = st.tabs(tabs)
|
| 77 |
|
| 78 |
# Sample interview questions
|
| 79 |
interview_questions = {
|
| 80 |
"💻 Technical": [
|
| 81 |
-
"Explain Object-Oriented Programming.",
|
| 82 |
-
"What are the differences between TCP and UDP?",
|
| 83 |
-
"How does a database index work?",
|
| 84 |
-
"What is the difference between REST and SOAP?",
|
| 85 |
-
"Explain Big O notation with an example."
|
| 86 |
],
|
| 87 |
-
"
|
| 88 |
-
"Tell me about yourself.",
|
| 89 |
-
"What are your strengths and weaknesses?",
|
| 90 |
-
"Describe a challenging project you worked on.",
|
| 91 |
-
"Why should we hire you?",
|
| 92 |
-
"Where do you see yourself in five years?"
|
| 93 |
],
|
| 94 |
-
"
|
| 95 |
-
"Solve: A train moving at 60 km/hr crosses a 200m bridge in how many seconds?",
|
| 96 |
-
"What is the next number in the sequence: 2, 6, 12, 20, 30, ...?",
|
| 97 |
-
"If a clock is 10 minutes fast, how will you correct it?",
|
| 98 |
-
"A room has 8 corners, each with a cat. How many cats are there in total?",
|
| 99 |
-
"Solve: Two pipes can fill a tank in 4 and 6 hours. How long to fill together?"
|
| 100 |
],
|
| 101 |
"🏢 Company-Specific": [
|
| 102 |
-
"What do you know about our company?",
|
| 103 |
-
"Why do you want to work at Google (or any company)?",
|
| 104 |
-
"How do you stay updated with the latest technologies?",
|
| 105 |
-
"What sets you apart from other candidates?",
|
| 106 |
-
"Describe a time you handled failure professionally."
|
| 107 |
],
|
| 108 |
-
"
|
| 109 |
-
"What is a linked list? Explain with an example.",
|
| 110 |
-
"How do you implement a binary search algorithm?",
|
| 111 |
-
"Explain quicksort and its time complexity.",
|
| 112 |
-
"What is dynamic programming and how is it used?",
|
| 113 |
-
"Describe the difference between a stack and a queue."
|
| 114 |
]
|
| 115 |
}
|
| 116 |
|
|
@@ -138,4 +143,36 @@ if user_prompt:
|
|
| 138 |
with st.chat_message("assistant"):
|
| 139 |
st.markdown(gemini_response.text)
|
| 140 |
except Exception as e:
|
| 141 |
-
st.error(f"Error processing your message: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Configure Streamlit page settings
|
| 10 |
st.set_page_config(
|
| 11 |
page_title="Interview Prep Assistant",
|
| 12 |
+
page_icon="🎯",
|
| 13 |
layout="wide",
|
| 14 |
)
|
| 15 |
|
|
|
|
| 17 |
st.markdown(
|
| 18 |
"""
|
| 19 |
<style>
|
| 20 |
+
<style>
|
| 21 |
+
/* Set light blue background for the whole page */
|
| 22 |
+
body, .stApp {
|
| 23 |
+
background-color: #E3F2FD;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
body {
|
| 28 |
+
background-color: #ADD8E6;
|
| 29 |
}
|
| 30 |
.stTabs [data-baseweb="tab-list"] {
|
| 31 |
justify-content: center;
|
| 32 |
}
|
| 33 |
.stTabs [data-baseweb="tab"] {
|
| 34 |
+
background-color: #E3F2FD;
|
| 35 |
+
border-radius: 20px;
|
| 36 |
font-weight: bold;
|
| 37 |
+
color: black;
|
| 38 |
+
padding: 10px;
|
|
|
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
+
.stTabs [data-baseweb="tab"][aria-selected="true"] {
|
| 41 |
+
background-color: #1E90FF;
|
| 42 |
+
color: white;
|
| 43 |
+
border-radius: 20px;
|
| 44 |
}
|
| 45 |
+
h2 {
|
| 46 |
+
color: #003366;
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
</style>
|
| 49 |
""",
|
|
|
|
| 54 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 55 |
|
| 56 |
if not GOOGLE_API_KEY:
|
| 57 |
+
st.error("🚨 API key not found! Please set the GOOGLE_API_KEY in your .env file.")
|
| 58 |
st.stop()
|
| 59 |
|
| 60 |
# Configure the Generative AI model
|
|
|
|
| 62 |
gen_ai.configure(api_key=GOOGLE_API_KEY)
|
| 63 |
model = gen_ai.GenerativeModel("gemini-pro")
|
| 64 |
except Exception as e:
|
| 65 |
+
st.error(f"❌ Error initializing the Gemini-Pro model: {e}")
|
| 66 |
st.stop()
|
| 67 |
|
| 68 |
# Initialize the chat session
|
|
|
|
| 70 |
try:
|
| 71 |
st.session_state.chat_session = model.start_chat(history=[])
|
| 72 |
except Exception as e:
|
| 73 |
+
st.error(f"❌ Error initializing chat session: {e}")
|
| 74 |
st.stop()
|
| 75 |
|
| 76 |
# Display chatbot title
|
| 77 |
st.title("🎯 Interview Prep Assistant")
|
| 78 |
|
| 79 |
# Tabs for category selection
|
| 80 |
+
tabs = ["💻 Technical", "💬 HR & Behavioral", "🧠 Aptitude", "🏢 Company-Specific", "📚 DSA"]
|
| 81 |
selected_tab = st.tabs(tabs)
|
| 82 |
|
| 83 |
# Sample interview questions
|
| 84 |
interview_questions = {
|
| 85 |
"💻 Technical": [
|
| 86 |
+
"🖥️ Explain Object-Oriented Programming.",
|
| 87 |
+
"🌐 What are the differences between TCP and UDP?",
|
| 88 |
+
"📂 How does a database index work?",
|
| 89 |
+
"🔗 What is the difference between REST and SOAP?",
|
| 90 |
+
"⚡ Explain Big O notation with an example."
|
| 91 |
],
|
| 92 |
+
"💬 HR & Behavioral": [
|
| 93 |
+
"🗣️ Tell me about yourself.",
|
| 94 |
+
"💪 What are your strengths and weaknesses?",
|
| 95 |
+
"📌 Describe a challenging project you worked on.",
|
| 96 |
+
"🎯 Why should we hire you?",
|
| 97 |
+
"📅 Where do you see yourself in five years?"
|
| 98 |
],
|
| 99 |
+
"🧠 Aptitude": [
|
| 100 |
+
"🚂 Solve: A train moving at 60 km/hr crosses a 200m bridge in how many seconds?",
|
| 101 |
+
"🔢 What is the next number in the sequence: 2, 6, 12, 20, 30, ...?",
|
| 102 |
+
"⏰ If a clock is 10 minutes fast, how will you correct it?",
|
| 103 |
+
"🐈 A room has 8 corners, each with a cat. How many cats are there in total?",
|
| 104 |
+
"🚰 Solve: Two pipes can fill a tank in 4 and 6 hours. How long to fill together?"
|
| 105 |
],
|
| 106 |
"🏢 Company-Specific": [
|
| 107 |
+
"🏢 What do you know about our company?",
|
| 108 |
+
"❓ Why do you want to work at Google (or any company)?",
|
| 109 |
+
"🔍 How do you stay updated with the latest technologies?",
|
| 110 |
+
"🏆 What sets you apart from other candidates?",
|
| 111 |
+
"⚠️ Describe a time you handled failure professionally."
|
| 112 |
],
|
| 113 |
+
"📚 DSA": [
|
| 114 |
+
"🔗 What is a linked list? Explain with an example.",
|
| 115 |
+
"📊 How do you implement a binary search algorithm?",
|
| 116 |
+
"🌀 Explain quicksort and its time complexity.",
|
| 117 |
+
"🎯 What is dynamic programming and how is it used?",
|
| 118 |
+
"📦 Describe the difference between a stack and a queue."
|
| 119 |
]
|
| 120 |
}
|
| 121 |
|
|
|
|
| 143 |
with st.chat_message("assistant"):
|
| 144 |
st.markdown(gemini_response.text)
|
| 145 |
except Exception as e:
|
| 146 |
+
st.error(f"❌ Error processing your message: {e}")
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
|