maahikachitagi commited on
Commit
68f6752
Β·
verified Β·
1 Parent(s): f737e92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -3,7 +3,7 @@ from huggingface_hub import InferenceClient
3
  import re
4
  import random
5
 
6
- # ---- Load and parse questions from knowledge.txt ----
7
  def load_questions(file_path):
8
  with open(file_path, 'r') as f:
9
  data = f.read()
@@ -20,7 +20,7 @@ def load_questions(file_path):
20
 
21
  all_questions = load_questions('knowledge.txt')
22
 
23
- # ---- Tagging ----
24
  questions_by_type = {
25
  'Technical': [q for q in all_questions if any(keyword in q['question'].lower() for keyword in [
26
  'function', 'linked list', 'url', 'rest', 'graphql', 'garbage', 'cap theorem', 'sql', 'hash table',
@@ -35,7 +35,7 @@ questions_by_type = {
35
 
36
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
37
 
38
- # ---- Logic functions ----
39
  def set_type(choice, user_profile):
40
  user_profile["interview_type"] = choice
41
  return "Great! What’s your background and what field/role are you aiming for?", user_profile
@@ -52,7 +52,7 @@ def respond(message, chat_history, user_profile):
52
  chat_history.append((message, bot_msg))
53
  return chat_history
54
 
55
- # Start interview logic
56
  if message_lower == 'start':
57
  interview_type = user_profile['interview_type']
58
  selected_questions = questions_by_type.get(interview_type, [])
@@ -96,7 +96,7 @@ def respond(message, chat_history, user_profile):
96
  chat_history.append((message, feedback))
97
  return chat_history
98
 
99
- # fallback small talk
100
  messages = [{"role": "system", "content": f"You are a professional interviewer conducting a {user_profile['interview_type']} interview for a candidate in {user_profile['field']}."}]
101
  for q, a in chat_history:
102
  messages.append({"role": "user", "content": q})
@@ -122,7 +122,7 @@ def generate_feedback(user_profile):
122
  feedback.append(fb)
123
  return "\n".join(feedback)
124
 
125
- # ---- Gradio UI ----
126
  with gr.Blocks() as demo:
127
  user_profile = gr.State({"interview_type": "", "field": "", "interview_in_progress": False})
128
  chat_history = gr.State([])
 
3
  import re
4
  import random
5
 
6
+ # uploading and cleaning the knowledge txt file
7
  def load_questions(file_path):
8
  with open(file_path, 'r') as f:
9
  data = f.read()
 
20
 
21
  all_questions = load_questions('knowledge.txt')
22
 
23
+ # creating the questions based on each interview
24
  questions_by_type = {
25
  'Technical': [q for q in all_questions if any(keyword in q['question'].lower() for keyword in [
26
  'function', 'linked list', 'url', 'rest', 'graphql', 'garbage', 'cap theorem', 'sql', 'hash table',
 
35
 
36
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
37
 
38
+ # setting up the users profile
39
  def set_type(choice, user_profile):
40
  user_profile["interview_type"] = choice
41
  return "Great! What’s your background and what field/role are you aiming for?", user_profile
 
52
  chat_history.append((message, bot_msg))
53
  return chat_history
54
 
55
+ # interview process
56
  if message_lower == 'start':
57
  interview_type = user_profile['interview_type']
58
  selected_questions = questions_by_type.get(interview_type, [])
 
96
  chat_history.append((message, feedback))
97
  return chat_history
98
 
99
+ # starting the chatbot
100
  messages = [{"role": "system", "content": f"You are a professional interviewer conducting a {user_profile['interview_type']} interview for a candidate in {user_profile['field']}."}]
101
  for q, a in chat_history:
102
  messages.append({"role": "user", "content": q})
 
122
  feedback.append(fb)
123
  return "\n".join(feedback)
124
 
125
+ # creating the visual elements
126
  with gr.Blocks() as demo:
127
  user_profile = gr.State({"interview_type": "", "field": "", "interview_in_progress": False})
128
  chat_history = gr.State([])