pradeepsengarr commited on
Commit
1e3e5fd
·
verified ·
1 Parent(s): 68b7816

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -20
app.py CHANGED
@@ -3,27 +3,36 @@ import faiss
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_values = list(resume_data.values())
23
 
24
  # Load embedding model
25
  model = SentenceTransformer('all-MiniLM-L6-v2')
26
- embeddings = model.encode(resume_values)
27
 
28
  # Store embeddings in FAISS index
29
  index = faiss.IndexFlatL2(embeddings.shape[1])
@@ -32,13 +41,28 @@ index.add(np.array(embeddings))
32
  def get_response(query):
33
  query_embedding = model.encode([query])
34
  D, I = index.search(query_embedding, 1)
35
- return resume_values[I[0][0]]
 
 
 
36
 
37
  # Streamlit UI
38
- st.title("📝 Resume Chatbot")
39
- st.write("Ask anything about Pradeep's resume!")
 
 
 
 
 
 
 
 
 
 
40
 
41
- user_input = st.text_input("Your question:")
42
  if user_input:
43
- response = get_response(user_input)
44
- st.success(f"**Answer:** {response}")
 
 
 
 
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
  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?")