Spaces:
Sleeping
Sleeping
“vinit5112”
commited on
Commit
·
52b027f
1
Parent(s):
45e068b
async conflict
Browse files- backend/Qdrant.py +2 -2
- backend/vector_store.py +6 -6
backend/Qdrant.py
CHANGED
@@ -43,7 +43,7 @@ class QdrantManager:
|
|
43 |
vector_size = 384
|
44 |
|
45 |
# Create collection with vector configuration
|
46 |
-
|
47 |
collection_name=collection_name,
|
48 |
vectors_config=models.VectorParams(
|
49 |
size=vector_size,
|
@@ -62,7 +62,7 @@ class QdrantManager:
|
|
62 |
}
|
63 |
|
64 |
for field_name, schema_type in payload_indices.items():
|
65 |
-
|
66 |
collection_name=collection_name,
|
67 |
field_name=field_name,
|
68 |
field_schema=schema_type
|
|
|
43 |
vector_size = 384
|
44 |
|
45 |
# Create collection with vector configuration
|
46 |
+
self.qdrant_client.create_collection(
|
47 |
collection_name=collection_name,
|
48 |
vectors_config=models.VectorParams(
|
49 |
size=vector_size,
|
|
|
62 |
}
|
63 |
|
64 |
for field_name, schema_type in payload_indices.items():
|
65 |
+
self.qdrant_client.create_payload_index(
|
66 |
collection_name=collection_name,
|
67 |
field_name=field_name,
|
68 |
field_schema=schema_type
|
backend/vector_store.py
CHANGED
@@ -64,7 +64,7 @@ class VectorStore:
|
|
64 |
"""
|
65 |
try:
|
66 |
# Try to get collection info - this is more reliable than just listing collections
|
67 |
-
collection_info =
|
68 |
print(f"Collection '{self.collection_name}' exists and is accessible")
|
69 |
return True
|
70 |
except Exception as e:
|
@@ -85,7 +85,7 @@ class VectorStore:
|
|
85 |
vector_size = 384
|
86 |
|
87 |
# Create collection with vector configuration
|
88 |
-
|
89 |
collection_name=self.collection_name,
|
90 |
vectors_config=models.VectorParams(
|
91 |
size=vector_size,
|
@@ -108,7 +108,7 @@ class VectorStore:
|
|
108 |
|
109 |
for field_name, schema_type in payload_indices.items():
|
110 |
try:
|
111 |
-
|
112 |
collection_name=self.collection_name,
|
113 |
field_name=field_name,
|
114 |
field_schema=schema_type
|
@@ -201,7 +201,7 @@ class VectorStore:
|
|
201 |
)
|
202 |
|
203 |
# Store in Qdrant
|
204 |
-
result =
|
205 |
collection_name=self.collection_name,
|
206 |
points=[point]
|
207 |
)
|
@@ -244,7 +244,7 @@ class VectorStore:
|
|
244 |
query_embedding = self.embedding_model.encode([query])[0]
|
245 |
|
246 |
# Search in Qdrant
|
247 |
-
results =
|
248 |
collection_name=self.collection_name,
|
249 |
query_vector=query_embedding.tolist(),
|
250 |
limit=limit
|
@@ -269,7 +269,7 @@ class VectorStore:
|
|
269 |
async def get_collection_info(self) -> Dict:
|
270 |
"""Get information about the collection"""
|
271 |
try:
|
272 |
-
collection_info =
|
273 |
return {
|
274 |
"name": collection_info.config.name,
|
275 |
"vector_size": collection_info.config.params.vectors.size,
|
|
|
64 |
"""
|
65 |
try:
|
66 |
# Try to get collection info - this is more reliable than just listing collections
|
67 |
+
collection_info = self.client.get_collection(self.collection_name)
|
68 |
print(f"Collection '{self.collection_name}' exists and is accessible")
|
69 |
return True
|
70 |
except Exception as e:
|
|
|
85 |
vector_size = 384
|
86 |
|
87 |
# Create collection with vector configuration
|
88 |
+
self.client.create_collection(
|
89 |
collection_name=self.collection_name,
|
90 |
vectors_config=models.VectorParams(
|
91 |
size=vector_size,
|
|
|
108 |
|
109 |
for field_name, schema_type in payload_indices.items():
|
110 |
try:
|
111 |
+
self.client.create_payload_index(
|
112 |
collection_name=self.collection_name,
|
113 |
field_name=field_name,
|
114 |
field_schema=schema_type
|
|
|
201 |
)
|
202 |
|
203 |
# Store in Qdrant
|
204 |
+
result = self.client.upsert(
|
205 |
collection_name=self.collection_name,
|
206 |
points=[point]
|
207 |
)
|
|
|
244 |
query_embedding = self.embedding_model.encode([query])[0]
|
245 |
|
246 |
# Search in Qdrant
|
247 |
+
results = self.client.search(
|
248 |
collection_name=self.collection_name,
|
249 |
query_vector=query_embedding.tolist(),
|
250 |
limit=limit
|
|
|
269 |
async def get_collection_info(self) -> Dict:
|
270 |
"""Get information about the collection"""
|
271 |
try:
|
272 |
+
collection_info = self.client.get_collection(self.collection_name)
|
273 |
return {
|
274 |
"name": collection_info.config.name,
|
275 |
"vector_size": collection_info.config.params.vectors.size,
|