Spaces:
Sleeping
Sleeping
Update app.py (#1)
Browse files- Update app.py (ba6ad99ac665254c6bffe15f14632424452dc103)
app.py
CHANGED
|
@@ -1,362 +1,163 @@
|
|
| 1 |
-
import PyPDF2
|
| 2 |
import streamlit as st
|
| 3 |
-
|
| 4 |
-
import
|
| 5 |
-
from
|
| 6 |
-
import
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
sentiment_model = pipeline('sentiment-analysis')
|
| 25 |
|
| 26 |
-
# Initialize Google Sheets connection
|
| 27 |
-
def initialize_google_sheets():
|
| 28 |
-
credentials = Credentials.from_service_account_file(CREDS_PATH, scopes=SCOPE)
|
| 29 |
try:
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
st.
|
| 35 |
-
return
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# Function to answer a query using Hugging Face's QA pipeline
|
| 50 |
-
def answer_query(question, context):
|
| 51 |
-
result = qa_pipeline(question=question, context=context)
|
| 52 |
-
return result['answer']
|
| 53 |
-
|
| 54 |
-
# Function to analyze sentiment using Hugging Face's pre-trained model
|
| 55 |
-
def analyze_sentiment(text):
|
| 56 |
-
sentiment = sentiment_model(text)[0] # Output is a list of dictionaries
|
| 57 |
-
label = sentiment['label']
|
| 58 |
-
score = sentiment['score']
|
| 59 |
-
|
| 60 |
-
# Define sentiment labels
|
| 61 |
-
if label == "POSITIVE" and score > 0.6:
|
| 62 |
-
sentiment_description = "Positive"
|
| 63 |
-
elif label == "NEGATIVE" and score < 0.4: # Adjust threshold for negative sentiment
|
| 64 |
-
sentiment_description = "Negative"
|
| 65 |
-
else:
|
| 66 |
-
sentiment_description = "Neutral"
|
| 67 |
-
|
| 68 |
-
return score, sentiment_description
|
| 69 |
-
|
| 70 |
-
# Function to update Google Sheets without product name
|
| 71 |
-
def update_sheet_without_product(sentiment_score, sentiment_description, relevant_answer):
|
| 72 |
-
if sheet:
|
| 73 |
-
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 74 |
-
sheet.append_row([timestamp, sentiment_description, sentiment_score, relevant_answer, "No Product Name"])
|
| 75 |
-
else:
|
| 76 |
-
st.error("Google Sheets connection not initialized.")
|
| 77 |
|
| 78 |
-
|
| 79 |
-
def suggest_product_recommendations(sentiment_description, query):
|
| 80 |
-
recommendations = []
|
| 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 |
-
recommendations = [
|
| 112 |
-
"Hereโs a list of the latest smartphones that might interest you."
|
| 113 |
-
]
|
| 114 |
-
elif "headphones" in query.lower():
|
| 115 |
-
if sentiment_description == "Positive":
|
| 116 |
-
recommendations = [
|
| 117 |
-
"These wireless headphones offer superior sound quality.",
|
| 118 |
-
"Looking for noise-cancelling headphones? Try these."
|
| 119 |
-
]
|
| 120 |
-
elif sentiment_description == "Negative":
|
| 121 |
-
recommendations = [
|
| 122 |
-
"Consider these alternative headphones with better reviews.",
|
| 123 |
-
"These highly-rated, affordable options might suit your needs."
|
| 124 |
-
]
|
| 125 |
-
else:
|
| 126 |
-
recommendations = [
|
| 127 |
-
"Check out these top-rated headphones for music lovers!"
|
| 128 |
-
]
|
| 129 |
-
elif "tablet" in query.lower():
|
| 130 |
-
if sentiment_description == "Positive":
|
| 131 |
-
recommendations = [
|
| 132 |
-
"Check out this lightweight tablet with amazing battery life.",
|
| 133 |
-
"This tablet has incredible processing power and an excellent screen."
|
| 134 |
-
]
|
| 135 |
-
elif sentiment_description == "Negative":
|
| 136 |
-
recommendations = [
|
| 137 |
-
"Hereโs an alternative tablet with a better display.",
|
| 138 |
-
"These budget tablets might be more up your alley."
|
| 139 |
-
]
|
| 140 |
-
else:
|
| 141 |
-
recommendations = [
|
| 142 |
-
"Looking for a tablet? Here are some of the best options right now."
|
| 143 |
-
]
|
| 144 |
-
elif "camera" in query.lower():
|
| 145 |
-
if sentiment_description == "Positive":
|
| 146 |
-
recommendations = [
|
| 147 |
-
"This camera offers stunning image quality for professionals.",
|
| 148 |
-
"Perfect for vloggers! Check out this high-quality camera."
|
| 149 |
-
]
|
| 150 |
-
elif sentiment_description == "Negative":
|
| 151 |
-
recommendations = [
|
| 152 |
-
"Maybe youโd prefer these budget-friendly cameras with better features.",
|
| 153 |
-
"Here are some alternatives for beginner photographers."
|
| 154 |
-
]
|
| 155 |
-
else:
|
| 156 |
-
recommendations = [
|
| 157 |
-
"Explore these top-rated cameras for your photography needs!"
|
| 158 |
-
]
|
| 159 |
else:
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
recognizer.adjust_for_ambient_noise(source) # Adjust for background noise
|
| 200 |
-
st.write("Listening...") # Optional: Add a message to indicate listening state
|
| 201 |
-
try:
|
| 202 |
-
audio = recognizer.listen(source, timeout=5, phrase_time_limit=10) # Listen for the audio input
|
| 203 |
-
st.write("Recognizing...") # Optional: Add a message for recognition process
|
| 204 |
-
text = recognizer.recognize_google(audio) # Use Google's speech recognition to convert audio to text
|
| 205 |
-
st.write(f"Recognized: {text}")
|
| 206 |
-
return text # Return the text detected from the audio
|
| 207 |
-
except sr.UnknownValueError:
|
| 208 |
-
st.error("Sorry, I could not understand the audio.") # Handle case when the audio is unclear
|
| 209 |
-
return None
|
| 210 |
-
except sr.RequestError:
|
| 211 |
-
st.error("Could not request results from Google Speech Recognition service.") # Handle network issues
|
| 212 |
-
return None
|
| 213 |
-
except Exception as e:
|
| 214 |
-
st.error(f"An error occurred: {e}")
|
| 215 |
-
return None
|
| 216 |
-
|
| 217 |
-
# Function to suggest related follow-up questions based on the answer
|
| 218 |
-
def suggest_related_questions():
|
| 219 |
-
related_questions = [
|
| 220 |
-
"Can you explain more about the product?",
|
| 221 |
-
"What are the features of this product?",
|
| 222 |
-
"How does it compare to other products?",
|
| 223 |
-
"Can I get more details about the specifications?",
|
| 224 |
-
"What is the price of the product?"
|
| 225 |
-
]
|
| 226 |
-
return related_questions
|
| 227 |
-
|
| 228 |
-
# Dashboard functions
|
| 229 |
-
def display_dashboard():
|
| 230 |
-
st.title("Customer Query Dashboard")
|
| 231 |
-
|
| 232 |
-
# Adding a background color and styles to enhance the dashboard appearance
|
| 233 |
-
st.markdown("""
|
| 234 |
-
<style>
|
| 235 |
-
.stApp {
|
| 236 |
-
background-color: #f0f4f8;
|
| 237 |
}
|
| 238 |
-
.stButton>button {
|
| 239 |
-
background-color: #4CAF50;
|
| 240 |
-
color: white;
|
| 241 |
-
border-radius: 10px;
|
| 242 |
-
padding: 10px 20px;
|
| 243 |
-
}
|
| 244 |
-
.stTextInput>div>input {
|
| 245 |
-
border-radius: 10px;
|
| 246 |
-
border: 2px solid #4CAF50;
|
| 247 |
-
padding: 10px;
|
| 248 |
-
}
|
| 249 |
-
</style>
|
| 250 |
-
""", unsafe_allow_html=True)
|
| 251 |
-
|
| 252 |
-
# Displaying a greeting message with animation
|
| 253 |
-
st.balloons() # Adding confetti animation when the page loads
|
| 254 |
-
|
| 255 |
-
if sheet:
|
| 256 |
-
data = pd.DataFrame(sheet.get_all_records()) # Load all rows into a DataFrame
|
| 257 |
-
|
| 258 |
-
# Ensure the Timestamp column exists and is in datetime format
|
| 259 |
-
if 'Timestamp' in data.columns:
|
| 260 |
-
data['Timestamp'] = pd.to_datetime(data['Timestamp'])
|
| 261 |
-
|
| 262 |
-
# Add a date filter to the dashboard
|
| 263 |
-
date_filter = st.selectbox("Filter by Date", ["All Time", "Today", "One Week"])
|
| 264 |
-
|
| 265 |
-
# Filter data based on the selected date range
|
| 266 |
-
if date_filter != "All Time":
|
| 267 |
-
data = filter_data_by_date(data, date_filter)
|
| 268 |
-
|
| 269 |
-
# Check if the required columns are present
|
| 270 |
-
if 'Sentiment' in data.columns and 'Answer' in data.columns:
|
| 271 |
-
# Filter by product (Amazon or Flipkart)
|
| 272 |
-
product_filter = st.selectbox("Select Product", ["All", "Amazon", "Flipkart"])
|
| 273 |
-
|
| 274 |
-
if product_filter != "All":
|
| 275 |
-
data = data[data['Product Name'] == product_filter]
|
| 276 |
-
|
| 277 |
-
# Plot sentiment distribution
|
| 278 |
-
sentiment_counts = data['Sentiment'].value_counts()
|
| 279 |
-
|
| 280 |
-
# Plot Sentiment Distribution using Plotly for better interactivity
|
| 281 |
-
st.subheader("Sentiment Distribution")
|
| 282 |
-
fig = px.bar(x=sentiment_counts.index, y=sentiment_counts.values,
|
| 283 |
-
labels={'x': 'Sentiment', 'y': 'Frequency'},
|
| 284 |
-
color=sentiment_counts.index,
|
| 285 |
-
color_discrete_map={"POSITIVE": "green", "NEGATIVE": "red", "NEUTRAL": "gray"})
|
| 286 |
-
st.plotly_chart(fig)
|
| 287 |
-
|
| 288 |
-
# Call Activity Statistics
|
| 289 |
-
total_calls = len(data)
|
| 290 |
-
avg_sentiment = data['Sentiment'].apply(lambda x: 1 if x == 'Positive' else -1 if x == 'Negative' else 0).mean()
|
| 291 |
-
avg_sentiment = round(avg_sentiment, 2)
|
| 292 |
-
|
| 293 |
-
st.subheader("Call Activity Statistics")
|
| 294 |
-
st.write(f"Total Calls: {total_calls}")
|
| 295 |
-
st.write(f"Average Sentiment: {avg_sentiment}")
|
| 296 |
-
|
| 297 |
-
# Download option for the entire history (PDF)
|
| 298 |
-
pdf = generate_pdf(data)
|
| 299 |
-
st.download_button(
|
| 300 |
-
label="Download Call History as PDF",
|
| 301 |
-
data=pdf,
|
| 302 |
-
file_name="call_history.pdf",
|
| 303 |
-
mime="application/pdf"
|
| 304 |
-
)
|
| 305 |
-
|
| 306 |
-
else:
|
| 307 |
-
st.error("The required columns (Sentiment, Answer) are not found in the data.")
|
| 308 |
-
st.write("Check the data structure in the Google Sheet to make sure the columns are correct.")
|
| 309 |
-
|
| 310 |
-
# Main Streamlit UI and workflow
|
| 311 |
-
def main():
|
| 312 |
-
st.title('Real-Time Customer Query Analysis & Call History')
|
| 313 |
-
|
| 314 |
-
# Sidebar Navigation
|
| 315 |
-
sidebar_option = st.sidebar.selectbox("Select an Option", ["Dashboard", "Call Analysis"])
|
| 316 |
|
| 317 |
-
|
| 318 |
-
|
|
|
|
| 319 |
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
uploaded_pdf = st.file_uploader("Upload a PDF file", type="pdf")
|
| 323 |
-
if uploaded_pdf:
|
| 324 |
-
pdf_text = extract_pdf_text_with_pypdf(uploaded_pdf)
|
| 325 |
|
| 326 |
-
|
| 327 |
-
st.error("No text could be extracted from the PDF.")
|
| 328 |
-
return
|
| 329 |
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
if user_input:
|
| 334 |
-
# Sentiment Analysis
|
| 335 |
-
sentiment_score, sentiment_description = analyze_sentiment(user_input)
|
| 336 |
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
st.write(f"Answer: {answer}")
|
| 340 |
|
| 341 |
-
|
| 342 |
-
|
|
|
|
| 343 |
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
st.write(f"- {recommendation}")
|
| 349 |
|
| 350 |
-
|
| 351 |
-
|
|
|
|
| 352 |
|
| 353 |
-
|
|
|
|
| 354 |
|
| 355 |
-
|
| 356 |
-
st.subheader("Related Follow-up Questions")
|
| 357 |
-
related_questions = suggest_related_questions()
|
| 358 |
-
for question in related_questions:
|
| 359 |
-
st.write(f"- {question}")
|
| 360 |
|
| 361 |
-
|
| 362 |
-
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
import os
|
| 4 |
+
from hashlib import sha256
|
| 5 |
+
import random
|
| 6 |
+
|
| 7 |
+
# ========== CONFIG ==========
|
| 8 |
+
GROQ_API_KEY = "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" # Replace with your actual key
|
| 9 |
+
GROQ_MODEL = "llama3-8b-8192" # Recommended current Groq model
|
| 10 |
+
|
| 11 |
+
# ========== STATE ==========
|
| 12 |
+
if "last_result" not in st.session_state:
|
| 13 |
+
st.session_state.last_result = None
|
| 14 |
+
if "last_candidate" not in st.session_state:
|
| 15 |
+
st.session_state.last_candidate = None
|
| 16 |
+
|
| 17 |
+
# ========== GROQ HELPERS ==========
|
| 18 |
+
|
| 19 |
+
def generate_questions(domain: str, round_type: str):
|
| 20 |
+
prompt = f"""
|
| 21 |
+
Generate 3 {round_type} interview questions for a candidate in the domain of {domain}.
|
| 22 |
+
Questions should be clear, concise, and assess relevant skills.
|
| 23 |
+
"""
|
| 24 |
+
headers = {"Authorization": f"Bearer {GROQ_API_KEY}", "Content-Type": "application/json"}
|
| 25 |
+
data = {
|
| 26 |
+
"model": GROQ_MODEL,
|
| 27 |
+
"messages": [{"role": "user", "content": prompt}],
|
| 28 |
+
"temperature": 0.7,
|
| 29 |
+
"max_tokens": 400,
|
| 30 |
+
}
|
| 31 |
|
| 32 |
+
response = requests.post("https://api.groq.com/openai/v1/chat/completions", headers=headers, json=data)
|
|
|
|
| 33 |
|
|
|
|
|
|
|
|
|
|
| 34 |
try:
|
| 35 |
+
res_json = response.json()
|
| 36 |
+
return [q.strip("- ").strip() for q in res_json['choices'][0]['message']['content'].split("\n") if q.strip()]
|
| 37 |
+
except Exception as e:
|
| 38 |
+
st.error(f"Groq API Error: {e}")
|
| 39 |
+
st.json(response.json())
|
| 40 |
+
return ["Question 1", "Question 2", "Question 3"]
|
| 41 |
+
|
| 42 |
+
def generate_programming_question(domain: str, language: str):
|
| 43 |
+
prompt = f"""
|
| 44 |
+
Generate 1 beginner-to-intermediate level programming interview question in {language} for a candidate applying in the domain of {domain}.
|
| 45 |
+
Provide only the question without solution or explanation.
|
| 46 |
+
"""
|
| 47 |
+
headers = {"Authorization": f"Bearer {GROQ_API_KEY}", "Content-Type": "application/json"}
|
| 48 |
+
data = {
|
| 49 |
+
"model": GROQ_MODEL,
|
| 50 |
+
"messages": [{"role": "user", "content": prompt}],
|
| 51 |
+
"temperature": 0.7,
|
| 52 |
+
"max_tokens": 300,
|
| 53 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
response = requests.post("https://api.groq.com/openai/v1/chat/completions", headers=headers, json=data)
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
try:
|
| 58 |
+
return response.json()['choices'][0]['message']['content']
|
| 59 |
+
except Exception as e:
|
| 60 |
+
st.error(f"Groq API Error: {e}")
|
| 61 |
+
st.json(response.json())
|
| 62 |
+
return "Write a function to reverse a string."
|
| 63 |
+
|
| 64 |
+
# ========== CORE FUNCTIONALITY ==========
|
| 65 |
+
|
| 66 |
+
def check_resume_originality(uploaded_file):
|
| 67 |
+
content = uploaded_file.read()
|
| 68 |
+
resume_hash = sha256(content).hexdigest()
|
| 69 |
+
existing_hashes = ["abc123", "def456"] # Dummy hashes - replace with real hashes database
|
| 70 |
+
return 20 if resume_hash in existing_hashes else 95
|
| 71 |
+
|
| 72 |
+
def save_to_crm(name, domain, result):
|
| 73 |
+
# Placeholder for CRM integration - replace with real CRM API calls
|
| 74 |
+
print(f"[CRM] Candidate: {name}, Domain: {domain}, Result: {result}")
|
| 75 |
+
|
| 76 |
+
def show_dashboard():
|
| 77 |
+
st.title("๐ Dashboard")
|
| 78 |
+
if st.session_state.last_result:
|
| 79 |
+
st.subheader("Latest Candidate Summary")
|
| 80 |
+
total_score = sum(st.session_state.last_result.values()) / len(st.session_state.last_result)
|
| 81 |
+
st.metric("Overall Score", f"{total_score:.2f}%")
|
| 82 |
+
st.progress(int(total_score))
|
| 83 |
+
for k, v in st.session_state.last_result.items():
|
| 84 |
+
st.write(f"**{k.replace('_', ' ').title()}**: {v:.2f}%")
|
| 85 |
+
st.info(f"Last candidate: {st.session_state.last_candidate}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
else:
|
| 87 |
+
st.warning("No interview data available yet.")
|
| 88 |
+
|
| 89 |
+
def start_interview(domain, language):
|
| 90 |
+
result = {}
|
| 91 |
+
|
| 92 |
+
st.subheader("๐ข Round 1: Aptitude")
|
| 93 |
+
aptitude_qs = generate_questions(domain, "aptitude")
|
| 94 |
+
aptitude_score = 0
|
| 95 |
+
for i, q in enumerate(aptitude_qs):
|
| 96 |
+
ans = st.text_input(f"Aptitude Q{i+1}: {q}", key=f"apt{i}")
|
| 97 |
+
if ans:
|
| 98 |
+
aptitude_score += 1
|
| 99 |
+
result['aptitude_score'] = (aptitude_score / len(aptitude_qs)) * 100
|
| 100 |
+
|
| 101 |
+
st.subheader(f"๐ป Round 2: Programming in {language}")
|
| 102 |
+
prog_q = generate_programming_question(domain, language)
|
| 103 |
+
st.markdown(f"**Problem:** {prog_q}")
|
| 104 |
+
code_ans = st.text_area(f"Write your solution in {language}", key="code")
|
| 105 |
+
result['code_score'] = 90 if ("def" in code_ans or "class" in code_ans) and len(code_ans) > 20 else 40
|
| 106 |
+
|
| 107 |
+
st.subheader("๐ฌ Round 3: HR Interview")
|
| 108 |
+
hr_qs = generate_questions(domain, "HR")
|
| 109 |
+
hr_score = 0
|
| 110 |
+
for i, q in enumerate(hr_qs):
|
| 111 |
+
ans = st.text_area(f"HR Q{i+1}: {q}", key=f"hr{i}")
|
| 112 |
+
hr_score += len(ans.split()) > 15
|
| 113 |
+
result['hr_score'] = (hr_score / len(hr_qs)) * 100
|
| 114 |
+
|
| 115 |
+
st.subheader("๐ฃ๏ธ Round 4: Communication")
|
| 116 |
+
result['communication_score'] = random.randint(70, 90)
|
| 117 |
+
|
| 118 |
+
# --- Show final marks summary ---
|
| 119 |
+
st.markdown("---")
|
| 120 |
+
st.header("๐ Interview Summary")
|
| 121 |
+
rounds = {
|
| 122 |
+
"Aptitude": result['aptitude_score'],
|
| 123 |
+
"Programming": result['code_score'],
|
| 124 |
+
"HR Interview": result['hr_score'],
|
| 125 |
+
"Communication": result['communication_score'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
+
total = sum(rounds.values()) / len(rounds)
|
| 129 |
+
for round_name, score in rounds.items():
|
| 130 |
+
st.write(f"**{round_name}:** {score:.2f}%")
|
| 131 |
|
| 132 |
+
st.write(f"### Overall Score: {total:.2f}%")
|
| 133 |
+
st.progress(int(total))
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
return result
|
|
|
|
|
|
|
| 136 |
|
| 137 |
+
# ========== MAIN APP ==========
|
| 138 |
+
st.set_page_config(page_title="AI Interview System", layout="centered")
|
| 139 |
+
page = st.sidebar.radio("๐ Navigate", ["Interview", "Dashboard"])
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
+
if page == "Interview":
|
| 142 |
+
st.title("๐ง AI Interview System")
|
|
|
|
| 143 |
|
| 144 |
+
uploaded_resume = st.file_uploader("๐ Upload Resume (PDF/DOCX)", type=['pdf', 'docx'])
|
| 145 |
+
domain = st.selectbox("๐ฏ Select your domain", ["Software", "Data Science", "Networking", "AI/ML"])
|
| 146 |
+
language = st.selectbox("๐ป Select programming language", ["Python", "Java", "C++", "JavaScript"])
|
| 147 |
|
| 148 |
+
if uploaded_resume and domain and language:
|
| 149 |
+
with st.expander("๐ Step 1: Resume Originality Check"):
|
| 150 |
+
score = check_resume_originality(uploaded_resume)
|
| 151 |
+
st.info(f"Resume Originality Score: **{score}%**")
|
|
|
|
| 152 |
|
| 153 |
+
if st.button("๐ Start Interview"):
|
| 154 |
+
result = start_interview(domain, language)
|
| 155 |
+
st.success("โ
Interview Completed!")
|
| 156 |
|
| 157 |
+
st.session_state.last_result = result
|
| 158 |
+
st.session_state.last_candidate = uploaded_resume.name
|
| 159 |
|
| 160 |
+
save_to_crm(uploaded_resume.name, domain, result)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
+
elif page == "Dashboard":
|
| 163 |
+
show_dashboard()
|