Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,11 @@ import pandas as pd
|
|
4 |
|
5 |
from functions import *
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
backgroundPattern = """
|
@@ -107,6 +112,33 @@ resume_combined.reset_index(drop=True, inplace=True)
|
|
107 |
|
108 |
#QDRANT VECTORIZER
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
|
112 |
|
|
|
4 |
|
5 |
from functions import *
|
6 |
|
7 |
+
from qdrant_client import QdrantClient
|
8 |
+
from qdrant_client.http.models import VectorParams, Distance, Record, Filter
|
9 |
+
from random import uniform
|
10 |
+
|
11 |
+
|
12 |
|
13 |
|
14 |
backgroundPattern = """
|
|
|
112 |
|
113 |
#QDRANT VECTORIZER
|
114 |
|
115 |
+
vector_dimension = encoder.model.get_sentence_embedding_dimension()
|
116 |
+
qdrant_interface = QdrantInterface(QUADRANT_ENDPOINT, QUADRANT_API_KEY, vector_dimension)
|
117 |
+
qdrant_interface.create_collection('jobs', Distance.COSINE)
|
118 |
+
qdrant_interface.create_collection('resumes', Distance.COSINE)
|
119 |
+
|
120 |
+
# Function to ensure vectors are in list format
|
121 |
+
def ensure_list_format(df, vector_col):
|
122 |
+
df[vector_col] = df[vector_col].apply(lambda x: x.tolist() if hasattr(x, 'tolist') else x)
|
123 |
+
return df
|
124 |
+
|
125 |
+
# Ensure vectors are in the correct format before uploading
|
126 |
+
jobs_combined = ensure_list_format(jobs_combined, 'summarized_description_encoded')
|
127 |
+
resume_combined = ensure_list_format(resume_combined, 'summarized_resume_encoded')
|
128 |
+
|
129 |
+
given_job_vector = jobs_combined['summarized_description_encoded'].iloc[0]
|
130 |
+
|
131 |
+
# Now upload to Qdrant
|
132 |
+
qdrant_interface.save_to_qdrant(jobs_combined, 'jobs', 'summarized_description_encoded', ['processed_title', 'processed_description', 'token_count', 'summarized_description'])
|
133 |
+
qdrant_interface.save_to_qdrant(resume_combined, 'resumes', 'summarized_resume_encoded', ['processed_resume', 'token_count', 'summarized_resume'])
|
134 |
+
|
135 |
+
# Retrieve specific records by IDs from the 'jobs' collection
|
136 |
+
specific_jobs_records = qdrant_interface.retrieve_specific_records('jobs', ids=[1])
|
137 |
+
|
138 |
+
# Find top 5 matching resumes for the example job
|
139 |
+
matched_resumes = qdrant_interface.match_jobs_to_resumes(given_job_vector, top_k=5)
|
140 |
+
for resume, score in matched_resumes:
|
141 |
+
print(f"Matched Resume: {resume['summarized_resume']}, Score: {score}")
|
142 |
|
143 |
|
144 |
|