Skip to content

Commit

Permalink
aws[patch]: Remove numpy dependency (previously patch to support nump…
Browse files Browse the repository at this point in the history
…y2) (#282)

Increasing version of numpy to include 2.x.x for the langchain-aws
package. Fixes #147

---------

Co-authored-by: Piyush Jain <[email protected]>
  • Loading branch information
ghinch and 3coins authored Nov 22, 2024
1 parent cf4d4be commit 1bf6ba5
Show file tree
Hide file tree
Showing 4 changed files with 332 additions and 280 deletions.
2 changes: 1 addition & 1 deletion libs/aws/langchain_aws/utilities/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def cosine_similarity_top_k(
score_threshold = score_threshold or -1.0
score_array[score_array < score_threshold] = 0
top_k = min(top_k or len(score_array), np.count_nonzero(score_array))
top_k_idxs = np.argpartition(score_array, -top_k, axis=None)[-top_k:]
top_k_idxs = np.argpartition(score_array, -top_k, axis=None)[-top_k:] # type: ignore
top_k_idxs = top_k_idxs[np.argsort(score_array.ravel()[top_k_idxs])][::-1]
ret_idxs = np.unravel_index(top_k_idxs, score_array.shape)
scores = score_array.ravel()[top_k_idxs].tolist()
Expand Down
2 changes: 1 addition & 1 deletion libs/aws/langchain_aws/vectorstores/inmemorydb/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class InMemoryDBVectorField(InMemoryDBField):
dims: int = Field(...)
algorithm: object = Field(...)
datatype: str = Field(default="FLOAT32")
distance_metric: InMemoryDBDistanceMetric = Field(default="COSINE")
distance_metric: InMemoryDBDistanceMetric = Field(default="COSINE") # type: ignore
initial_cap: Optional[int] = None

@field_validator("algorithm", "datatype", "distance_metric", mode="before")
Expand Down
Loading

0 comments on commit 1bf6ba5

Please sign in to comment.