Skip to content

Commit

Permalink
fix(vectorstores.py): fetch embedding for the near_vector method
Browse files Browse the repository at this point in the history
the near_vector method accepts a parameter called "near_vector", for which the method will perform vector search to get the nearest vector(s). We should get the vector using the embedding object, just as we did in the `hybrid` search method, 4 lines above it.
  • Loading branch information
hkhairy committed Mar 24, 2024
1 parent 2cc1ccb commit d0552ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion langchain_weaviate/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,12 @@ def _perform_search(
query=query, vector=embedding, limit=k, **kwargs
)
elif search_method == "near_vector":
result = collection.query.near_vector(limit=k, **kwargs)
embedding = self._embedding.embed_query(query)
result = collection.query.near_vector(
near_vector = embedding,
limit=k,
**kwargs
)
else:
raise ValueError(f"Invalid search method: {search_method}")
except weaviate.exceptions.WeaviateQueryException as e:
Expand Down

0 comments on commit d0552ac

Please sign in to comment.