Update main/vector_store.py
Browse files- main/vector_store.py +9 -2
main/vector_store.py
CHANGED
@@ -200,6 +200,13 @@ class QdrantVectorStore:
|
|
200 |
)
|
201 |
|
202 |
# Format results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
results = []
|
204 |
for result in search_results:
|
205 |
results.append(
|
@@ -207,7 +214,7 @@ class QdrantVectorStore:
|
|
207 |
"id": result.payload.get("article_id", ""),
|
208 |
"title": result.payload.get("title", ""),
|
209 |
"content": result.payload.get("content", ""),
|
210 |
-
"score": result.score,
|
211 |
"metadata": result.payload.get("metadata", {}),
|
212 |
}
|
213 |
)
|
@@ -241,4 +248,4 @@ class QdrantVectorStore:
|
|
241 |
self.client.delete_collection(self.collection_name)
|
242 |
print(f"Deleted collection: {self.collection_name}")
|
243 |
except Exception as e:
|
244 |
-
print(f"Error deleting collection: {e}")
|
|
|
200 |
)
|
201 |
|
202 |
# Format results
|
203 |
+
scores = []
|
204 |
+
for result in search_results:
|
205 |
+
scores.append(result.score)
|
206 |
+
|
207 |
+
max_score = max(scores)
|
208 |
+
min_score = min(scores)
|
209 |
+
|
210 |
results = []
|
211 |
for result in search_results:
|
212 |
results.append(
|
|
|
214 |
"id": result.payload.get("article_id", ""),
|
215 |
"title": result.payload.get("title", ""),
|
216 |
"content": result.payload.get("content", ""),
|
217 |
+
"score": float((result.score - min_score) / (max_score - min_score)) if max_score > 0 and min_score > 0 and max_score != min_score else 0,
|
218 |
"metadata": result.payload.get("metadata", {}),
|
219 |
}
|
220 |
)
|
|
|
248 |
self.client.delete_collection(self.collection_name)
|
249 |
print(f"Deleted collection: {self.collection_name}")
|
250 |
except Exception as e:
|
251 |
+
print(f"Error deleting collection: {e}")
|