mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-05 04:38:26 +00:00
community: (milvus) check for num_shards (#20603)
@rgupta2508 I believe this change is necessary following
https://github.com/langchain-ai/langchain/pull/20318 because of how
Milvus handles defaults:
59bf5e811a/pymilvus/client/prepare.py (L82-L85)
```python
num_shards = kwargs[next(iter(same_key))]
if not isinstance(num_shards, int):
msg = f"invalid num_shards type, got {type(num_shards)}, expected int"
raise ParamError(message=msg)
req.shards_num = num_shards
```
this way lets Milvus control the default value (instead of maintaining a
separate default in Langchain).
Let me know if I've got this wrong or you feel it's unnecessary. Thanks.
This commit is contained in:
parent
25c4c24e89
commit
c897264b9b
@ -378,13 +378,23 @@ class Milvus(VectorStore):
|
|||||||
|
|
||||||
# Create the collection
|
# Create the collection
|
||||||
try:
|
try:
|
||||||
self.col = Collection(
|
if self.num_shards is not None:
|
||||||
name=self.collection_name,
|
# Issue with defaults:
|
||||||
schema=schema,
|
# https://github.com/milvus-io/pymilvus/blob/59bf5e811ad56e20946559317fed855330758d9c/pymilvus/client/prepare.py#L82-L85
|
||||||
consistency_level=self.consistency_level,
|
self.col = Collection(
|
||||||
using=self.alias,
|
name=self.collection_name,
|
||||||
num_shards=self.num_shards,
|
schema=schema,
|
||||||
)
|
consistency_level=self.consistency_level,
|
||||||
|
using=self.alias,
|
||||||
|
num_shards=self.num_shards,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.col = Collection(
|
||||||
|
name=self.collection_name,
|
||||||
|
schema=schema,
|
||||||
|
consistency_level=self.consistency_level,
|
||||||
|
using=self.alias,
|
||||||
|
)
|
||||||
# Set the collection properties if they exist
|
# Set the collection properties if they exist
|
||||||
if self.collection_properties is not None:
|
if self.collection_properties is not None:
|
||||||
self.col.set_properties(self.collection_properties)
|
self.col.set_properties(self.collection_properties)
|
||||||
|
Loading…
Reference in New Issue
Block a user