Spaces:
Sleeping
Sleeping
minor changes
Browse files- qdrant_setup.py +2 -43
qdrant_setup.py
CHANGED
|
@@ -220,7 +220,6 @@ def get_context_for_questions(
|
|
| 220 |
|
| 221 |
def get_context_single(question: str) -> str:
|
| 222 |
results = search_in_qdrant(question)
|
| 223 |
-
print(results)
|
| 224 |
if results:
|
| 225 |
return results[0]['payload'].get('text', '')
|
| 226 |
return ''
|
|
@@ -241,46 +240,6 @@ def get_context_for_questions(
|
|
| 241 |
|
| 242 |
return contexts
|
| 243 |
|
| 244 |
-
def print_all_points(
|
| 245 |
-
qdrant_client: QdrantClient = client,
|
| 246 |
-
collection: str = collection_name,
|
| 247 |
-
batch_size: int = 100
|
| 248 |
-
) -> None:
|
| 249 |
-
"""
|
| 250 |
-
Iterate over all points in the collection and print their id, score (if any), and payload.
|
| 251 |
-
Uses the scroll API to page through everything without needing to know total size upfront.
|
| 252 |
-
"""
|
| 253 |
-
offset = None # For scroll, initial call has no offset/token
|
| 254 |
-
total_printed = 0
|
| 255 |
-
|
| 256 |
-
while True:
|
| 257 |
-
# Scroll returns next batch; depending on Qdrant version it may use `offset` or a cursor-like parameter.
|
| 258 |
-
resp = qdrant_client.scroll(
|
| 259 |
-
collection_name=collection,
|
| 260 |
-
limit=batch_size,
|
| 261 |
-
with_payload=True,
|
| 262 |
-
)
|
| 263 |
-
print(resp)
|
| 264 |
-
points = resp.points
|
| 265 |
-
if not points:
|
| 266 |
-
break
|
| 267 |
-
|
| 268 |
-
for p in points:
|
| 269 |
-
print(f"ID: {p.id}")
|
| 270 |
-
if hasattr(p, "score") and p.score is not None:
|
| 271 |
-
print(f" Score: {p.score}")
|
| 272 |
-
print(f" Payload: {p.payload}")
|
| 273 |
-
total_printed += 1
|
| 274 |
-
|
| 275 |
-
# Prepare next offset / cursor; adapt depending on response shape
|
| 276 |
-
# Newer versions return `next_page_offset` or similar
|
| 277 |
-
offset = getattr(resp, "next_page_offset", None)
|
| 278 |
-
if offset is None:
|
| 279 |
-
# If no offset/cursor is provided, assume we've exhausted results
|
| 280 |
-
break
|
| 281 |
-
|
| 282 |
-
print(f"Total points printed: {total_printed}")
|
| 283 |
-
|
| 284 |
if __name__=="__main__":
|
| 285 |
# import time
|
| 286 |
# t1=time.time()
|
|
@@ -304,5 +263,5 @@ if __name__=="__main__":
|
|
| 304 |
# print(get_context_for_questions(questions)==get_context_for_questions_parallel(questions))
|
| 305 |
# t2=time.time()
|
| 306 |
# print("time taken",t2-t1)
|
| 307 |
-
|
| 308 |
-
print_all_points()
|
|
|
|
| 220 |
|
| 221 |
def get_context_single(question: str) -> str:
|
| 222 |
results = search_in_qdrant(question)
|
|
|
|
| 223 |
if results:
|
| 224 |
return results[0]['payload'].get('text', '')
|
| 225 |
return ''
|
|
|
|
| 240 |
|
| 241 |
return contexts
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
if __name__=="__main__":
|
| 244 |
# import time
|
| 245 |
# t1=time.time()
|
|
|
|
| 263 |
# print(get_context_for_questions(questions)==get_context_for_questions_parallel(questions))
|
| 264 |
# t2=time.time()
|
| 265 |
# print("time taken",t2-t1)
|
| 266 |
+
print(search_in_qdrant("What is the grace period for premium payment under the National Parivar Mediclaim Plus Policy?"))
|
| 267 |
+
#print_all_points()
|