Skip to content

Commit

Permalink
type changes for weaviate and qdrant files
Browse files Browse the repository at this point in the history
  • Loading branch information
AmoghTantradi committed Jan 16, 2025
1 parent ccd9e48 commit 89bf974
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lotus/vector_store/qdrant_vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __call__(
indices = []

for result in results:
indices.append(result.payload["doc_id"])
indices.append(result.id)
distances.append(result.score) # Qdrant returns cosine similarity directly

# Pad results if fewer than K matches
Expand All @@ -125,8 +125,8 @@ def __call__(
all_indices.append(indices)

return RMOutput(
distances=np.array(all_distances, dtype=np.float32),
indices=np.array(all_indices, dtype=np.int64)
distances=np.array(all_distances, dtype=np.float32).tolist(),
indices=np.array(all_indices, dtype=np.int64).tolist()
)

def get_vectors_from_index(self, collection_name: str, ids: list[int]) -> NDArray[np.float64]:
Expand Down
4 changes: 2 additions & 2 deletions lotus/vector_store/weaviate_vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __call__(self,
limit=K,
return_metadata=MetadataQuery(distance=True)
))
response.objects[0].metadata.distance
response.objects[0].uuid
results.append(response)

# Process results into expected format
Expand All @@ -116,7 +116,7 @@ def __call__(self,
distances:List[float] = []
indices = []
for obj in objects:
indices.append(obj.properties.get('content'))
indices.append(obj.uuid)
# Convert cosine distance to similarity score
distance = obj.metadata.distance if obj.metadata and obj.metadata.distance is not None else 1.0
distances.append(1 - distance) # Convert distance to similarity
Expand Down

0 comments on commit 89bf974

Please sign in to comment.