Upload folder using huggingface_hub
Browse files
scripts/test_qdrant_client.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from qdrant_client import QdrantClient, models
|
| 2 |
+
|
| 3 |
+
try:
|
| 4 |
+
print("Checking QdrantClient methods...")
|
| 5 |
+
client = QdrantClient(location=":memory:")
|
| 6 |
+
client.create_collection("test", vectors_config=models.VectorParams(size=4, distance=models.Distance.COSINE))
|
| 7 |
+
client.upsert("test", points=[
|
| 8 |
+
models.PointStruct(id=1, vector=[0.1, 0.1, 0.1, 0.1], payload={"text": "hello"})
|
| 9 |
+
])
|
| 10 |
+
|
| 11 |
+
print("Testing query_points...")
|
| 12 |
+
results = client.query_points(
|
| 13 |
+
collection_name="test",
|
| 14 |
+
query=[0.1, 0.1, 0.1, 0.1],
|
| 15 |
+
limit=1
|
| 16 |
+
)
|
| 17 |
+
print(f"Results type: {type(results)}")
|
| 18 |
+
print(f"Results attributes: {dir(results)}")
|
| 19 |
+
if hasattr(results, 'points'):
|
| 20 |
+
print(f"Points type: {type(results.points)}")
|
| 21 |
+
print(f"First point: {results.points[0]}")
|
| 22 |
+
print(f"First point payload: {results.points[0].payload}")
|
| 23 |
+
if hasattr(client, 'search'):
|
| 24 |
+
print("client.search exists")
|
| 25 |
+
else:
|
| 26 |
+
print("client.search DOES NOT exist")
|
| 27 |
+
|
| 28 |
+
except Exception as e:
|
| 29 |
+
print(f"Error: {e}")
|
src/embeddings/vector_store.py
CHANGED
|
@@ -228,9 +228,9 @@ class QdrantVectorStore:
|
|
| 228 |
|
| 229 |
def search(self, query_embedding, n_results=5, filter_metadata=None):
|
| 230 |
# Qdrant expects query_vector
|
| 231 |
-
|
| 232 |
collection_name=self.collection_name,
|
| 233 |
-
|
| 234 |
limit=n_results
|
| 235 |
)
|
| 236 |
|
|
@@ -239,7 +239,7 @@ class QdrantVectorStore:
|
|
| 239 |
metadatas = []
|
| 240 |
distances = []
|
| 241 |
|
| 242 |
-
for res in
|
| 243 |
docs.append(res.payload.get("page_content", ""))
|
| 244 |
metadatas.append({k:v for k,v in res.payload.items() if k != "page_content"})
|
| 245 |
distances.append(res.score)
|
|
|
|
| 228 |
|
| 229 |
def search(self, query_embedding, n_results=5, filter_metadata=None):
|
| 230 |
# Qdrant expects query_vector
|
| 231 |
+
response = self.client.query_points(
|
| 232 |
collection_name=self.collection_name,
|
| 233 |
+
query=query_embedding,
|
| 234 |
limit=n_results
|
| 235 |
)
|
| 236 |
|
|
|
|
| 239 |
metadatas = []
|
| 240 |
distances = []
|
| 241 |
|
| 242 |
+
for res in response.points:
|
| 243 |
docs.append(res.payload.get("page_content", ""))
|
| 244 |
metadatas.append({k:v for k,v in res.payload.items() if k != "page_content"})
|
| 245 |
distances.append(res.score)
|