pradeepsengarr commited on
Commit
162e462
·
verified ·
1 Parent(s): 1e3e5fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -41
app.py CHANGED
@@ -3,36 +3,28 @@ import faiss
3
  import numpy as np
4
  from sentence_transformers import SentenceTransformer
5
 
6
- # Load resume data in structured format
7
  resume_data = {
8
- "Name": "Pradeep Singh Sengar",
9
- "LinkedIn": "[LinkedIn Profile](https://www.linkedin.com/in/pradeepsengarr)",
10
- "Email": "[email protected]",
11
- "GitHub": "[GitHub Profile](https://github.com/pradeepsengar)",
12
- "Mobile": "+91-7898367211",
13
- "Education": "Bachelor of Engineering (Hons.) - Information Technology (CGPA: 8.31, Oriental College Of Technology, Bhopal, 2019-2023)",
14
- "Skills": "Python, HTML/CSS, Django, React.js, Node.js, Git, Web Scraping, Generative AI, Machine Learning (LLM)",
15
- "Experience": "Graduate Engineer Trainee at Jio Platform Limited (Dec. 2023 - Present). Implemented chatbots with Docker, used Git/GitHub, worked with LLM concepts and Hugging Face.",
16
- "Projects": "Room Rental System, Text to Image Generator, Fitness Tracker, Movie Recommendation System",
17
- "Certifications": "Salesforce AI Associate, Web Development (Internshala), Data Science (LinkedIn Learning)",
 
18
  }
19
 
20
- # Suggested common questions
21
- suggested_questions = [
22
- "What are your key skills?",
23
- "Tell me about your work experience?",
24
- "What projects have you worked on?",
25
- "What certifications do you have?",
26
- "How can I contact you?",
27
- ]
28
-
29
- # Convert resume data to list for embedding
30
  resume_keys = list(resume_data.keys())
31
  resume_values = list(resume_data.values())
32
 
33
  # Load embedding model
34
  model = SentenceTransformer('all-MiniLM-L6-v2')
35
- embeddings = model.encode(resume_keys)
36
 
37
  # Store embeddings in FAISS index
38
  index = faiss.IndexFlatL2(embeddings.shape[1])
@@ -41,28 +33,43 @@ index.add(np.array(embeddings))
41
  def get_response(query):
42
  query_embedding = model.encode([query])
43
  D, I = index.search(query_embedding, 1)
44
- score = 1 - (D[0][0] / np.max(D)) # Convert distance to similarity
45
- key = resume_keys[I[0][0]]
46
- response = resume_data[key]
47
- return key, response, round(score * 100, 2)
 
 
48
 
49
  # Streamlit UI
50
- st.set_page_config(page_title="Resume Chatbot", page_icon="🤖", layout="centered")
51
- st.title("🤖 Chat with My Resume")
52
- st.write("Ask me anything about my resume or pick a question below:")
53
 
54
- # Suggested questions UI
55
- cols = st.columns(len(suggested_questions))
 
 
 
 
 
 
 
 
 
 
56
  for i, question in enumerate(suggested_questions):
57
- if cols[i].button(question):
58
- user_input = question
59
-
60
- # User input box
61
- user_input = st.text_input("Your question:", key="user_query")
 
 
 
 
 
62
 
 
 
63
  if user_input:
64
- key, response, confidence = get_response(user_input)
65
- if confidence > 50:
66
- st.success(f"**{key}:** {response} (Confidence: {confidence}%)")
67
- else:
68
- st.warning("I'm not sure about this. Can you ask in a different way?")
 
3
  import numpy as np
4
  from sentence_transformers import SentenceTransformer
5
 
6
+ # Load resume data
7
  resume_data = {
8
+ "name": "Pradeep Singh Sengar",
9
+ "linkedin": "www.linkedin.com/in/ipradeepsengarr",
10
+ "email": "[email protected]",
11
+ "github": "github.com/pradeepsengar",
12
+ "mobile": "+91-7898367211",
13
+ "education": "Bachelor of Engineering (Hons.) - Information Technology; CGPA: 8.31 (Oriental College Of Technology, Bhopal, 2019-2023)",
14
+ "skills": "Python, HTML/CSS, Django, Reactjs, Node.js, Git, Web Scraping, Generative AI, Machine Learning (LLM)",
15
+ "experience": "Graduate Engineer Trainee at Jio Platform Limited (Dec. 2023 - Present). Implemented chatbots with Docker, used Git/GitHub, worked with LLM concepts and Hugging Face.",
16
+ "projects": "Room Rental System, Text to Image Generator, Fitness Tracker, Movie Recommendation System",
17
+ "honors_awards": "Qualified for Round 1B of SnackDown (CodeChef), Startup Challenge (Top 10 teams)",
18
+ "certifications": "Web Development (Internshala), The Complete Python Pro Bootcamp (Udemy), Data Science (LinkedIn Learning), Web Scraping (LinkedIn Learning)"
19
  }
20
 
21
+ # Convert data to list of sentences for retrieval
 
 
 
 
 
 
 
 
 
22
  resume_keys = list(resume_data.keys())
23
  resume_values = list(resume_data.values())
24
 
25
  # Load embedding model
26
  model = SentenceTransformer('all-MiniLM-L6-v2')
27
+ embeddings = model.encode(resume_values)
28
 
29
  # Store embeddings in FAISS index
30
  index = faiss.IndexFlatL2(embeddings.shape[1])
 
33
  def get_response(query):
34
  query_embedding = model.encode([query])
35
  D, I = index.search(query_embedding, 1)
36
+ confidence = 1 - D[0][0] / 10 # Normalize confidence score
37
+
38
+ if confidence > 0.5:
39
+ return f"**{resume_keys[I[0][0]].capitalize()}**: {resume_values[I[0][0]]} \n\n *(Confidence: {confidence:.2f})*"
40
+ else:
41
+ return "I'm not sure about this. Please try asking differently or be more specific."
42
 
43
  # Streamlit UI
44
+ st.title("📝 Resume Chatbot")
45
+ st.write("Ask anything about Pradeep's resume!")
 
46
 
47
+ # Suggested Questions
48
+ suggested_questions = [
49
+ "What is your name?",
50
+ "What is your LinkedIn profile?",
51
+ "What skills do you have?",
52
+ "Tell me about your experience?",
53
+ "What are your certifications?",
54
+ "List your projects."
55
+ ]
56
+
57
+ st.write("### Quick Questions")
58
+ col1, col2 = st.columns(2)
59
  for i, question in enumerate(suggested_questions):
60
+ if i % 2 == 0:
61
+ with col1:
62
+ if st.button(question, key=f"btn_{i}"):
63
+ st.session_state["user_input"] = question
64
+ st.rerun()
65
+ else:
66
+ with col2:
67
+ if st.button(question, key=f"btn_{i}"):
68
+ st.session_state["user_input"] = question
69
+ st.rerun()
70
 
71
+ # User Input & Response
72
+ user_input = st.text_input("Your question:", value=st.session_state.get("user_input", ""))
73
  if user_input:
74
+ response = get_response(user_input)
75
+ st.success(response)