@@ -26,13 +26,10 @@ def __init__(self, resume_processor, neo4j_model):
26
26
self .graph_chain = self .neo4j_model .get_graph_chain ()
27
27
28
28
# Define the PromptTemplate with 'context' as input variable
29
- prompt = PromptTemplate (
30
- template = """
31
- You are an expert Cypher query writer for a Neo4j graph database.
29
+ template = """
30
+ You are an assistant that matches resumes to relevant job descriptions.
32
31
33
- Given the user's question, generate an efficient Cypher query that:
34
- - extract entities and relationships from the following resume.
35
- - Focus solely on the resume content.
32
+ Given the user's resume, find the most relevant job descriptions.
36
33
37
34
**Entities to Extract:**
38
35
- **Education (Edu):** Details about degrees, fields of study, institutions, start and end years, GPA.
@@ -42,30 +39,20 @@ def __init__(self, resume_processor, neo4j_model):
42
39
- **Certifications (Cert):** Certification names, issuing organizations, expiration dates.
43
40
- **Soft Skills (SSkill):** Non-technical skills like leadership, communication.
44
41
45
- **Relationships to Identify:**
46
- - **UTILIZES_SKILL:** A Work Experience (WE) node utilizes a Skill (Skill) node.
47
- - **USES_TECH:** A Project (Proj) node uses a Skill (Skill) node as a technology.
48
- - **REL_TO (Proj to Skill):** A Project (Proj) node is related to a Skill (Skill) node.
49
- - **REL_TO (Skill to Skill):** A Skill (Skill) node is similar to another Skill (Skill) node.
50
-
51
42
**Resume:**
52
43
\" \" \"
53
44
{context}
54
45
\" \" \"
55
- """ ,
56
- input_variables = ["input" ]
57
- )
58
-
59
- # Create a documents chain
60
- self .combine_docs_chain = create_stuff_documents_chain (self .llm , prompt = prompt )
46
+ """
61
47
62
- # Initialize Retrieval Chain
63
- # Default node_label is 'JD'; can be adjusted as needed
64
- self .retrieval_chain = create_retrieval_chain (
65
- self .neo4j_model .get_retriever (node_label = "JD" ),
66
- self .combine_docs_chain
48
+ self .prompt_template = PromptTemplate (
49
+ template = template ,
50
+ input_variables = ["input" ]
67
51
)
68
52
53
+ # Create a documents chain
54
+ self .combine_docs_chain = create_stuff_documents_chain (self .llm , self .prompt_template )
55
+
69
56
def perform_mixed_retrieval (self , resume_text , node_label = "JD" ):
70
57
"""
71
58
Perform mixed retrieval using vector similarity and graph traversal.
@@ -89,14 +76,21 @@ def perform_mixed_retrieval(self, resume_text, node_label="JD"):
89
76
# Access the schema property correctly
90
77
schema = self .neo4j_model .graph .get_schema
91
78
79
+ # Get the retriever for the given node label
80
+ retriever = self .neo4j_model .get_retriever (node_label = node_label )
81
+
82
+ # Create the retrieval chain with the retriever and the combine_docs_chain
83
+ retrieval_chain = create_retrieval_chain (
84
+ retriever ,
85
+ self .combine_docs_chain
86
+ )
87
+
92
88
# Perform vector similarity search
93
- similar_docs_result = self . retrieval_chain .invoke ({"input" : resume_text }) # Corrected to 'context'
89
+ similar_docs_result = retrieval_chain .invoke ({"input" : resume_text }) # Corrected to 'context'
94
90
similar_docs = similar_docs_result .get ("output" , [])
95
91
print ("similar_docs_result:" , similar_docs_result )
96
92
print ("Keys in similar_docs_result:" , similar_docs_result .keys ())
97
93
98
-
99
-
100
94
for doc in similar_docs :
101
95
print ("Document Metadata:" , doc .metadata )
102
96
0 commit comments