Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,138 +1,431 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
import random
|
| 3 |
-
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
model =
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
Their answer was: "{answer}"
|
| 17 |
-
|
| 18 |
-
Please do the following:
|
| 19 |
-
1. Rate the answer from 1 to 10 based on relevance, clarity, and depth.
|
| 20 |
-
2. Provide detailed feedback on how the answer can be improved in a single line.
|
| 21 |
-
Respond in the format:
|
| 22 |
-
1. **Rating:** <score>/10
|
| 23 |
-
2. **Feedback:** <your feedback here>
|
| 24 |
-
"""
|
| 25 |
-
response = model.generate_content(info)
|
| 26 |
-
text = response.text.strip()
|
| 27 |
-
lines = text.split("\n")
|
| 28 |
-
score = -1
|
| 29 |
-
feedback = "Feedback not found"
|
| 30 |
-
for line in lines:
|
| 31 |
-
if "**Rating:**" in line:
|
| 32 |
-
try:
|
| 33 |
-
score = int(line.split("**Rating:**")[1].split("/")[0].strip())
|
| 34 |
-
except:
|
| 35 |
-
score = -1
|
| 36 |
-
elif "**Feedback:**" in line:
|
| 37 |
-
feedback = line.split("**Feedback:**")[1].strip()
|
| 38 |
-
return [score, feedback]
|
| 39 |
-
|
| 40 |
-
def finalsummary(feedback_list):
|
| 41 |
-
prompt = f"""
|
| 42 |
-
You are given a list of feedback. Summarize it and give 5–6 final suggestions for improvement.
|
| 43 |
-
feedback={feedback_list}
|
| 44 |
-
"""
|
| 45 |
-
response = model.generate_content(prompt)
|
| 46 |
-
return response.text
|
| 47 |
|
| 48 |
-
#
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
"ml": [
|
| 51 |
"What is supervised learning? Give an example.",
|
| 52 |
"What is the difference between classification and regression?",
|
| 53 |
"How does linear regression work?",
|
| 54 |
"What are decision trees and how do they work?",
|
| 55 |
-
"What is overfitting vs underfitting?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
],
|
| 57 |
-
"
|
| 58 |
-
"
|
| 59 |
-
"
|
| 60 |
-
"
|
| 61 |
-
"
|
| 62 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
]
|
| 64 |
}
|
| 65 |
|
| 66 |
-
#
|
|
|
|
|
|
|
|
|
|
| 67 |
session = {
|
| 68 |
"questions": [],
|
| 69 |
"current_index": 0,
|
| 70 |
-
"answers": [],
|
| 71 |
"scores": [],
|
| 72 |
-
"feedbacks": []
|
|
|
|
| 73 |
}
|
| 74 |
|
| 75 |
-
#
|
| 76 |
-
def
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
# Evaluate
|
| 92 |
question = session["questions"][session["current_index"]]
|
| 93 |
-
|
| 94 |
-
session["
|
| 95 |
-
session["scores"].append(score)
|
| 96 |
-
session["feedbacks"].append(fb)
|
| 97 |
|
|
|
|
|
|
|
|
|
|
| 98 |
session["current_index"] += 1
|
| 99 |
|
| 100 |
if session["current_index"] < len(session["questions"]):
|
| 101 |
next_q = session["questions"][session["current_index"]]
|
| 102 |
-
return next_q, gr.update(visible=True)
|
| 103 |
else:
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
def
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
)
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
submit_btn.click(submit_answer, inputs=audio_input,
|
| 135 |
-
outputs=[question_output, audio_input, final_output, detailed_output])
|
| 136 |
-
detailed_btn.click(show_detailed_feedback, outputs=detailed_output)
|
| 137 |
|
| 138 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import google.generativeai as genai
|
| 3 |
+
import os
|
| 4 |
import random
|
| 5 |
+
import whisper
|
| 6 |
|
| 7 |
+
# ========== Gemini API Setup (fallback with 2 keys) ==========
|
| 8 |
+
API_KEYS = [os.getenv("API_KEY_1"), os.getenv("API_KEY_2")]
|
| 9 |
+
model = None
|
| 10 |
|
| 11 |
+
def initialize_model():
|
| 12 |
+
global model
|
| 13 |
+
for key in API_KEYS:
|
| 14 |
+
try:
|
| 15 |
+
genai.configure(api_key=key)
|
| 16 |
+
model = genai.GenerativeModel("gemini-2.0-flash")
|
| 17 |
+
test = model.generate_content("Hello!")
|
| 18 |
+
if "Hello" in test.text:
|
| 19 |
+
print(f"[INFO] Using Gemini API key ending with: ...{key[-4:]}")
|
| 20 |
+
return
|
| 21 |
+
except Exception as e:
|
| 22 |
+
print(f"[WARNING] Gemini key failed: {e}")
|
| 23 |
+
raise RuntimeError("All Gemini API keys failed.")
|
| 24 |
|
| 25 |
+
initialize_model()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
# ========== Questions ==========
|
| 28 |
+
all_questions = {
|
| 29 |
+
"general": [
|
| 30 |
+
"Tell me about yourself.",
|
| 31 |
+
"What are your strengths and weaknesses?",
|
| 32 |
+
"How do you handle stress or pressure?",
|
| 33 |
+
"Describe a time when you worked in a team.",
|
| 34 |
+
"How do you manage your time and prioritize tasks?",
|
| 35 |
+
"Why do you want to join this company?",
|
| 36 |
+
"Where do you see yourself in 5 years?",
|
| 37 |
+
"Describe a challenge or conflict you faced and how you dealt with it.",
|
| 38 |
+
"What motivates you to do your best?",
|
| 39 |
+
"How do you handle feedback and criticism?",
|
| 40 |
+
"Tell me about a time you took initiative.",
|
| 41 |
+
"How do you stay organized during busy schedules?",
|
| 42 |
+
"What do you do when you face a task you don’t know how to solve?",
|
| 43 |
+
"Tell me about a mistake you made and what you learned from it.",
|
| 44 |
+
"Have you ever led a project or team? What was your experience?",
|
| 45 |
+
"How do you manage deadlines when working on multiple tasks?",
|
| 46 |
+
"Why should we hire you?",
|
| 47 |
+
"Tell me about a time you failed. How did you respond?",
|
| 48 |
+
"How do you approach learning something new?",
|
| 49 |
+
"What do you know about our company?",
|
| 50 |
+
"How do you balance quality and speed in your work?",
|
| 51 |
+
"Describe a time when you had to make a difficult decision.",
|
| 52 |
+
"How do you communicate in a remote or hybrid work environment?",
|
| 53 |
+
"What kind of work culture are you most comfortable in?",
|
| 54 |
+
"Do you prefer working independently or in a team? Why?"
|
| 55 |
+
],
|
| 56 |
+
"web development": [
|
| 57 |
+
"What is the difference between HTML and XHTML?",
|
| 58 |
+
"Explain how RESTful APIs work.",
|
| 59 |
+
"What are the advantages of using React over plain JavaScript?",
|
| 60 |
+
"How does the virtual DOM improve performance?",
|
| 61 |
+
"What are HTTP methods? Explain each.",
|
| 62 |
+
"What is the difference between sessionStorage and localStorage?",
|
| 63 |
+
"What is CORS and how do you handle it?",
|
| 64 |
+
"Explain the box model in CSS.",
|
| 65 |
+
"What is responsive design?",
|
| 66 |
+
"What is the difference between SQL and NoSQL databases?",
|
| 67 |
+
"What are web sockets and when are they used?",
|
| 68 |
+
"What is a service worker in PWA?",
|
| 69 |
+
"What is lazy loading and why is it useful?",
|
| 70 |
+
"Difference between GET and POST requests?",
|
| 71 |
+
"How does server-side rendering differ from client-side rendering?",
|
| 72 |
+
"What is Next.js and how is it different from React?",
|
| 73 |
+
"What is a CDN and how does it help?",
|
| 74 |
+
"What is HTTPS and why is it important?",
|
| 75 |
+
"Explain the concept of middleware in Express.js.",
|
| 76 |
+
"What is an ORM and why use it?",
|
| 77 |
+
"Explain MVC architecture.",
|
| 78 |
+
"What is the difference between PUT and PATCH requests?",
|
| 79 |
+
"What is GraphQL and how does it compare to REST?",
|
| 80 |
+
"How do cookies and sessions work?",
|
| 81 |
+
"What is JWT and how is it used in authentication?"
|
| 82 |
+
],
|
| 83 |
+
"devops": [
|
| 84 |
+
"What is CI/CD and why is it important?",
|
| 85 |
+
"Explain the concept of Infrastructure as Code.",
|
| 86 |
+
"What is Docker and how is it different from a virtual machine?",
|
| 87 |
+
"What are containers and how do they help in deployment?",
|
| 88 |
+
"What is Kubernetes used for?",
|
| 89 |
+
"How do you monitor applications in production?",
|
| 90 |
+
"What is the role of Jenkins in DevOps?",
|
| 91 |
+
"What are some popular logging tools?",
|
| 92 |
+
"Explain blue-green deployment.",
|
| 93 |
+
"What is Ansible used for?",
|
| 94 |
+
"What is Terraform and how is it used?",
|
| 95 |
+
"What is a build pipeline?",
|
| 96 |
+
"What is Helm in Kubernetes?",
|
| 97 |
+
"What is a rolling update in deployments?",
|
| 98 |
+
"Explain canary deployments.",
|
| 99 |
+
"What is load balancing and how does it work?",
|
| 100 |
+
"What is the difference between horizontal and vertical scaling?",
|
| 101 |
+
"What are artifacts in a CI/CD pipeline?",
|
| 102 |
+
"What is the use of Prometheus and Grafana?",
|
| 103 |
+
"What is a reverse proxy?",
|
| 104 |
+
"How do you ensure zero-downtime deployments?",
|
| 105 |
+
"Explain the role of GitOps.",
|
| 106 |
+
"What are secrets management tools?",
|
| 107 |
+
"What is the purpose of using NGINX in DevOps?",
|
| 108 |
+
"What is a container registry?"
|
| 109 |
+
],
|
| 110 |
+
"cybersecurity": [
|
| 111 |
+
"What is the difference between symmetric and asymmetric encryption?",
|
| 112 |
+
"What is SQL injection and how do you prevent it?",
|
| 113 |
+
"What are some common types of malware?",
|
| 114 |
+
"What is the CIA triad?",
|
| 115 |
+
"What is multi-factor authentication?",
|
| 116 |
+
"What are firewalls and how do they work?",
|
| 117 |
+
"Explain HTTPS and how it secures data.",
|
| 118 |
+
"What is penetration testing?",
|
| 119 |
+
"How do you secure an API?",
|
| 120 |
+
"What are some best practices for password security?",
|
| 121 |
+
"What is phishing and how can it be prevented?",
|
| 122 |
+
"What is social engineering?",
|
| 123 |
+
"What is a DDoS attack?",
|
| 124 |
+
"What are intrusion detection systems?",
|
| 125 |
+
"What is a VPN and how does it work?",
|
| 126 |
+
"What is data encryption at rest vs in transit?",
|
| 127 |
+
"What is a zero-day vulnerability?",
|
| 128 |
+
"Explain role-based access control (RBAC).",
|
| 129 |
+
"What is a digital certificate?",
|
| 130 |
+
"How does a public key infrastructure (PKI) work?",
|
| 131 |
+
"What is a man-in-the-middle attack?",
|
| 132 |
+
"What are honeypots in cybersecurity?",
|
| 133 |
+
"Explain sandboxing in malware analysis.",
|
| 134 |
+
"What are security patches?",
|
| 135 |
+
"What is OWASP Top 10?"
|
| 136 |
+
],
|
| 137 |
+
"ai": [
|
| 138 |
+
"What is the difference between AI, ML, and Deep Learning?",
|
| 139 |
+
"Explain a neural network and how it learns.",
|
| 140 |
+
"What is gradient descent?",
|
| 141 |
+
"What is the role of activation functions in neural networks?",
|
| 142 |
+
"Explain supervised vs. unsupervised learning.",
|
| 143 |
+
"What is backpropagation?",
|
| 144 |
+
"What is overfitting and how do you avoid it?",
|
| 145 |
+
"What is transfer learning?",
|
| 146 |
+
"What are some common use-cases of AI?",
|
| 147 |
+
"How do you evaluate a classification model?",
|
| 148 |
+
"What is reinforcement learning?",
|
| 149 |
+
"What is an autoencoder?",
|
| 150 |
+
"Explain convolutional neural networks (CNNs).",
|
| 151 |
+
"What are recurrent neural networks (RNNs)?",
|
| 152 |
+
"What is a transformer model?",
|
| 153 |
+
"What is attention mechanism in NLP?",
|
| 154 |
+
"What is the Turing test?",
|
| 155 |
+
"What are generative adversarial networks (GANs)?",
|
| 156 |
+
"What is the bias-variance tradeoff?",
|
| 157 |
+
"What is explainable AI (XAI)?",
|
| 158 |
+
"How do you train a deep learning model?",
|
| 159 |
+
"What is early stopping in training?",
|
| 160 |
+
"What are hyperparameters?",
|
| 161 |
+
"What is a confusion matrix?",
|
| 162 |
+
"What is the role of regularization in deep learning?"
|
| 163 |
+
],
|
| 164 |
"ml": [
|
| 165 |
"What is supervised learning? Give an example.",
|
| 166 |
"What is the difference between classification and regression?",
|
| 167 |
"How does linear regression work?",
|
| 168 |
"What are decision trees and how do they work?",
|
| 169 |
+
"What is overfitting vs underfitting?",
|
| 170 |
+
"Explain cross-validation and its importance.",
|
| 171 |
+
"What is regularization in machine learning?",
|
| 172 |
+
"What is the difference between bagging and boosting?",
|
| 173 |
+
"What is the role of a cost function?",
|
| 174 |
+
"How do you handle missing data in ML datasets?",
|
| 175 |
+
"What is the k-nearest neighbors (KNN) algorithm?",
|
| 176 |
+
"What is support vector machine (SVM)?",
|
| 177 |
+
"What is Naive Bayes algorithm?",
|
| 178 |
+
"What is logistic regression?",
|
| 179 |
+
"What is feature scaling and why is it needed?",
|
| 180 |
+
"What is principal component analysis (PCA)?",
|
| 181 |
+
"What is model drift?",
|
| 182 |
+
"How do you tune hyperparameters?",
|
| 183 |
+
"What is grid search and random search?",
|
| 184 |
+
"What are ensemble models?",
|
| 185 |
+
"What is a confusion matrix and what do its values represent?",
|
| 186 |
+
"How do you balance an imbalanced dataset?",
|
| 187 |
+
"What is precision-recall tradeoff?",
|
| 188 |
+
"What is ROC-AUC score?",
|
| 189 |
+
"What is the purpose of stratified sampling?"
|
| 190 |
],
|
| 191 |
+
"mobile development": [
|
| 192 |
+
"What is the difference between native and hybrid apps?",
|
| 193 |
+
"Explain the lifecycle of an Android activity.",
|
| 194 |
+
"What is Flutter and why use it?",
|
| 195 |
+
"How do you handle data persistence in mobile apps?",
|
| 196 |
+
"What is MVVM architecture?",
|
| 197 |
+
"Explain push notifications and how they work.",
|
| 198 |
+
"What are the limitations of mobile development?",
|
| 199 |
+
"How do you optimize performance in mobile apps?",
|
| 200 |
+
"What is the role of App Store Optimization (ASO)?",
|
| 201 |
+
"Explain the concept of responsive design in mobile.",
|
| 202 |
+
"What is the difference between Android and iOS development?",
|
| 203 |
+
"What is React Native and how does it work?",
|
| 204 |
+
"How do you handle offline mode in apps?",
|
| 205 |
+
"What is a RecyclerView?",
|
| 206 |
+
"Explain intents in Android.",
|
| 207 |
+
"What is dependency injection in Android?",
|
| 208 |
+
"What are permissions in mobile apps?",
|
| 209 |
+
"How do you debug a mobile app?",
|
| 210 |
+
"What is Jetpack Compose?",
|
| 211 |
+
"How is state management handled in Flutter?",
|
| 212 |
+
"What is a storyboard in iOS?",
|
| 213 |
+
"What are background services?",
|
| 214 |
+
"How do you handle API calls in mobile apps?",
|
| 215 |
+
"What is the difference between LiveData and Flow?",
|
| 216 |
+
"How do you publish an app to Google Play Store?"
|
| 217 |
+
],
|
| 218 |
+
"uiux": [
|
| 219 |
+
"What is the difference between UI and UX?",
|
| 220 |
+
"What are some principles of good UX design?",
|
| 221 |
+
"What is a user journey?",
|
| 222 |
+
"How do you conduct user testing?",
|
| 223 |
+
"What tools do you use for UI/UX design?",
|
| 224 |
+
"What is wireframing?",
|
| 225 |
+
"How do you design for accessibility?",
|
| 226 |
+
"What is the role of prototyping?",
|
| 227 |
+
"Explain the concept of design thinking.",
|
| 228 |
+
"How do you collect and incorporate user feedback?",
|
| 229 |
+
"What is the importance of consistency in UI design?",
|
| 230 |
+
"What is heuristic evaluation?",
|
| 231 |
+
"What is the role of typography in UI?",
|
| 232 |
+
"What are color theory principles?",
|
| 233 |
+
"How does UX impact business goals?",
|
| 234 |
+
"What is A/B testing in UI/UX?",
|
| 235 |
+
"What is microcopy and why is it important?",
|
| 236 |
+
"Explain responsive vs adaptive design.",
|
| 237 |
+
"What is a user persona?",
|
| 238 |
+
"What is interaction design?",
|
| 239 |
+
"What is a high-fidelity vs low-fidelity prototype?",
|
| 240 |
+
"How do you measure UX success?",
|
| 241 |
+
"What is card sorting?",
|
| 242 |
+
"What are accessibility standards (WCAG)?",
|
| 243 |
+
"What is the role of animation in UI?"
|
| 244 |
+
],
|
| 245 |
+
"data analytics": [
|
| 246 |
+
"What is the difference between descriptive and inferential statistics?",
|
| 247 |
+
"What are some common data cleaning techniques?",
|
| 248 |
+
"Explain how to deal with missing data.",
|
| 249 |
+
"What is the role of data visualization?",
|
| 250 |
+
"What is a pivot table?",
|
| 251 |
+
"What are outliers and how do you handle them?",
|
| 252 |
+
"Explain correlation vs causation.",
|
| 253 |
+
"What are some commonly used data analytics tools?",
|
| 254 |
+
"How do you handle large datasets efficiently?",
|
| 255 |
+
"What is ETL and how does it work?",
|
| 256 |
+
"What is a histogram and when is it used?",
|
| 257 |
+
"What is data wrangling?",
|
| 258 |
+
"What is the difference between mean, median, and mode?",
|
| 259 |
+
"What is standard deviation and variance?",
|
| 260 |
+
"What is a box plot?",
|
| 261 |
+
"What is a time series analysis?",
|
| 262 |
+
"What is the difference between R and Python for analytics?",
|
| 263 |
+
"What is the use of SQL in data analytics?",
|
| 264 |
+
"How do dashboards help in analytics?",
|
| 265 |
+
"What is cohort analysis?",
|
| 266 |
+
"What is hypothesis testing?",
|
| 267 |
+
"What are confidence intervals?",
|
| 268 |
+
"How do you avoid bias in analytics?",
|
| 269 |
+
"What is the purpose of a heatmap?",
|
| 270 |
+
"What is a funnel analysis?"
|
| 271 |
+
],
|
| 272 |
+
"data scientist": [
|
| 273 |
+
"What is the difference between supervised and unsupervised learning?",
|
| 274 |
+
"Explain bias-variance tradeoff in machine learning.",
|
| 275 |
+
"How do you handle imbalanced datasets?",
|
| 276 |
+
"What are precision, recall, and F1-score? Why are they important?",
|
| 277 |
+
"Describe a machine learning project you've worked on.",
|
| 278 |
+
"What is feature engineering? Give examples.",
|
| 279 |
+
"How do you select important variables in a dataset?",
|
| 280 |
+
"Explain overfitting and how to prevent it.",
|
| 281 |
+
"What’s the difference between bagging and boosting?",
|
| 282 |
+
"Describe the steps in a typical machine learning pipeline.",
|
| 283 |
+
"What tools do you use as a data scientist?",
|
| 284 |
+
"What is dimensionality reduction?",
|
| 285 |
+
"How do you evaluate regression models?",
|
| 286 |
+
"What is the difference between ROC and PR curves?",
|
| 287 |
+
"What is model interpretability?",
|
| 288 |
+
"How do you deploy a machine learning model?",
|
| 289 |
+
"What is a recommendation system?",
|
| 290 |
+
"How do you deal with outliers?",
|
| 291 |
+
"What is SMOTE?",
|
| 292 |
+
"What is A/B testing in data science?",
|
| 293 |
+
"How do you build a data pipeline?",
|
| 294 |
+
"What are data lakes and data warehouses?",
|
| 295 |
+
"What is a baseline model?",
|
| 296 |
+
"How do you perform EDA (Exploratory Data Analysis)?",
|
| 297 |
+
"What is clustering and what are its applications?"
|
| 298 |
+
],
|
| 299 |
+
"prompt engineering": [
|
| 300 |
+
"What is prompt engineering and why is it important?",
|
| 301 |
+
"How do temperature and top_p affect model output in LLMs?",
|
| 302 |
+
"How do you write a good system prompt for a chatbot?",
|
| 303 |
+
"What are the risks of prompt injection attacks?",
|
| 304 |
+
"What is chain-of-thought prompting?",
|
| 305 |
+
"How does few-shot prompting improve performance?",
|
| 306 |
+
"What are embeddings, and how are they used in retrieval-augmented generation?",
|
| 307 |
+
"What are the limitations of prompt-based techniques?",
|
| 308 |
+
"Explain the role of role-based prompts in function calling.",
|
| 309 |
+
"How would you structure a prompt to summarize a large document accurately?",
|
| 310 |
+
"What is zero-shot learning in prompt design?",
|
| 311 |
+
"What is in-context learning?",
|
| 312 |
+
"What is semantic search and how is it used with LLMs?",
|
| 313 |
+
"How do you evaluate the output of an LLM?",
|
| 314 |
+
"What is hallucination in LLMs?",
|
| 315 |
+
"What are guardrails in LLM applications?",
|
| 316 |
+
"What is prompt chaining?",
|
| 317 |
+
"How do you personalize prompts for users?",
|
| 318 |
+
"What are system vs user prompts?",
|
| 319 |
+
"What is instruction tuning?",
|
| 320 |
+
"How do you manage memory in prompt-based agents?",
|
| 321 |
+
"What is RAG (retrieval-augmented generation)?",
|
| 322 |
+
"What is the difference between deterministic and probabilistic LLM output?",
|
| 323 |
+
"How do prompts interact with tools in agent systems?",
|
| 324 |
+
"How do you test prompt robustness?"
|
| 325 |
]
|
| 326 |
}
|
| 327 |
|
| 328 |
+
# ========== Whisper ASR ==========
|
| 329 |
+
whisper_model = whisper.load_model("base")
|
| 330 |
+
|
| 331 |
+
# ========== Session State ==========
|
| 332 |
session = {
|
| 333 |
"questions": [],
|
| 334 |
"current_index": 0,
|
|
|
|
| 335 |
"scores": [],
|
| 336 |
+
"feedbacks": [],
|
| 337 |
+
"transcripts": []
|
| 338 |
}
|
| 339 |
|
| 340 |
+
# ========== Gemini Evaluation ==========
|
| 341 |
+
def get_score(question, answer):
|
| 342 |
+
prompt = f"""
|
| 343 |
+
You are an interview expert. A user was asked:
|
| 344 |
+
|
| 345 |
+
Question: {question}
|
| 346 |
+
|
| 347 |
+
Their answer was: "{answer}"
|
| 348 |
|
| 349 |
+
Please:
|
| 350 |
+
1. Rate from 1 to 10 based on clarity, relevance, and depth.
|
| 351 |
+
2. Give a 1-line constructive feedback.
|
| 352 |
+
|
| 353 |
+
Format:
|
| 354 |
+
1. **Rating:** <score>/10
|
| 355 |
+
2. **Feedback:** <text>
|
| 356 |
+
"""
|
| 357 |
+
response = model.generate_content(prompt).text.strip()
|
| 358 |
+
score = -1
|
| 359 |
+
feedback = "Feedback not found"
|
| 360 |
+
for line in response.split("\n"):
|
| 361 |
+
if "**Rating:**" in line:
|
| 362 |
+
try:
|
| 363 |
+
score = int(line.split("**Rating:**")[1].split("/")[0].strip())
|
| 364 |
+
except:
|
| 365 |
+
pass
|
| 366 |
+
elif "**Feedback:**" in line:
|
| 367 |
+
feedback = line.split("**Feedback:**")[1].strip()
|
| 368 |
+
return score, feedback
|
| 369 |
+
|
| 370 |
+
# ========== Summary ==========
|
| 371 |
+
def summarize_feedback(feedbacks):
|
| 372 |
+
prompt = "Summarize the following feedback into 4-5 improvement tips:\n" + "\n".join(feedbacks)
|
| 373 |
+
return model.generate_content(prompt).text.strip()
|
| 374 |
+
|
| 375 |
+
# ========== Audio Transcription ==========
|
| 376 |
+
def handle_audio(audio):
|
| 377 |
+
if not audio:
|
| 378 |
+
return "No audio provided"
|
| 379 |
+
result = whisper_model.transcribe(audio)
|
| 380 |
+
return result["text"]
|
| 381 |
+
|
| 382 |
+
# ========== Process Each Answer ==========
|
| 383 |
+
def run_session(audio):
|
| 384 |
+
if session["current_index"] >= len(session["questions"]):
|
| 385 |
+
return "✅ Interview complete!", gr.update(visible=False)
|
| 386 |
|
|
|
|
| 387 |
question = session["questions"][session["current_index"]]
|
| 388 |
+
transcript = handle_audio(audio)
|
| 389 |
+
session["transcripts"].append(transcript)
|
|
|
|
|
|
|
| 390 |
|
| 391 |
+
score, feedback = get_score(question, transcript)
|
| 392 |
+
session["scores"].append(score)
|
| 393 |
+
session["feedbacks"].append(f"Q{session['current_index']+1}: {feedback}")
|
| 394 |
session["current_index"] += 1
|
| 395 |
|
| 396 |
if session["current_index"] < len(session["questions"]):
|
| 397 |
next_q = session["questions"][session["current_index"]]
|
| 398 |
+
return f"🗣️ Answer: {transcript}\n\n🔢 Score: {score}/10\n💬 Feedback: {feedback}\n\n➡️ Next: {next_q}", gr.update(visible=True)
|
| 399 |
else:
|
| 400 |
+
avg_score = sum(session["scores"]) / len(session["scores"])
|
| 401 |
+
summary = summarize_feedback(session["feedbacks"])
|
| 402 |
+
return f"✅ Interview Complete!\n\n📊 Avg Score: {avg_score:.2f}/10\n\n📝 Summary:\n{summary}", gr.update(visible=False)
|
| 403 |
+
|
| 404 |
+
# ========== Start New Session ==========
|
| 405 |
+
def start_session(field):
|
| 406 |
+
general_qs = random.sample(all_questions["general"], 10)
|
| 407 |
+
domain_qs = random.sample(all_questions[field], 10)
|
| 408 |
+
session["questions"] = general_qs + domain_qs
|
| 409 |
+
random.shuffle(session["questions"])
|
| 410 |
+
session["current_index"] = 0
|
| 411 |
+
session["scores"] = []
|
| 412 |
+
session["feedbacks"] = []
|
| 413 |
+
session["transcripts"] = []
|
| 414 |
+
return session["questions"][0], gr.update(visible=True)
|
| 415 |
+
|
| 416 |
+
# ========== Gradio UI ==========
|
| 417 |
+
with gr.Blocks() as demo:web development
|
| 418 |
+
gr.Markdown("## 🎤 AI Mock Interview (Voice-Based) — 20 Questions")
|
| 419 |
+
with gr.Row():
|
| 420 |
+
field = gr.Dropdown(label="Select your domain", choices=["ml", "data science","web development","devops","cybersecurity","ai","mobile development","uiux","data analytics","prompt engineering"], value="data science")
|
| 421 |
+
start_btn = gr.Button("Start Interview")
|
| 422 |
+
|
| 423 |
+
question_display = gr.Textbox(label="Current Question", interactive=False)
|
| 424 |
+
audio_input = gr.Audio(type="filepath", label="🎙️ Speak your answer")
|
| 425 |
+
submit_btn = gr.Button("Submit Answer", visible=False)
|
| 426 |
+
output = gr.Textbox(label="Feedback", lines=8)
|
| 427 |
+
|
| 428 |
+
start_btn.click(start_session, inputs=field, outputs=[question_display, submit_btn])
|
| 429 |
+
submit_btn.click(run_session, inputs=audio_input, outputs=[output, submit_btn])
|
|
|
|
|
|
|
|
|
|
| 430 |
|
| 431 |
demo.launch()
|