Spaces:
Running
Running
Update app.py
Browse files
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 |
-
"
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
"
|
| 17 |
-
"
|
| 18 |
-
"certifications": "Web Development (Internshala), The Complete Python Pro Bootcamp (Udemy), Data Science (LinkedIn Learning), Web Scraping (LinkedIn Learning)"
|
| 19 |
}
|
| 20 |
|
| 21 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
resume_values = list(resume_data.values())
|
| 23 |
|
| 24 |
# Load embedding model
|
| 25 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 26 |
-
embeddings = model.encode(
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Streamlit UI
|
| 38 |
-
st.
|
| 39 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
user_input = st.text_input("Your question:")
|
| 42 |
if user_input:
|
| 43 |
-
response = get_response(user_input)
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 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": "pradeep19sengar@gmail.com",
|
| 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?")
|