Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: RPC error: [batch_insert], <ParamError: (code=1, message=expect string input, got: <class 'int'>)>, <Time:{'RPC start': '2024-05-13 01:07:12.372386', 'RPC error': '2024-05-13 01:07:12.372994'}> #4001

Open
zmwstu opened this issue May 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@zmwstu
Copy link

zmwstu commented May 13, 2024

2024-05-13 01:07:12,373 - decorators.py[line:146] - ERROR: RPC error: [batch_insert], <ParamError: (code=1, message=expect string input, got: <class 'int'>)>, <Time:{'RPC start': '2024-05-13 01:07:12.372386', 'RPC error': '2024-05-13 01:07:12.372994'}>
2024-05-13 01:07:12,373 - milvus.py[line:595] - ERROR: Failed to insert batch starting at entity: 0/25499
Traceback (most recent call last):
File "/home/zwm/Code_Program/Chatchat/milvus-Langchain-Chatchat/init_database.py", line 113, in
folder2db(kb_names=args.kb_name, mode="increment", embed_model=args.embed_model)
File "/home/zwm/Code_Program/Chatchat/milvus-Langchain-Chatchat/server/knowledge_base/migrate.py", line 150, in folder2db
files2vs(kb_name, kb_files)
File "/home/zwm/Code_Program/Chatchat/milvus-Langchain-Chatchat/server/knowledge_base/migrate.py", line 113, in files2vs
kb.add_doc(kb_file=kb_file, not_refresh_vs_cache=True)
File "/home/zwm/Code_Program/Chatchat/milvus-Langchain-Chatchat/server/knowledge_base/kb_service/base.py", line 131, in add_doc
doc_infos = self.do_add_doc(docs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/Code_Program/Chatchat/milvus-Langchain-Chatchat/server/knowledge_base/kb_service/milvus_kb_service.py", line 88, in do_add_doc
ids = self.milvus.add_documents(docs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/langchain_core/vectorstores.py", line 119, in add_documents
return self.add_texts(texts, metadatas, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/langchain_community/vectorstores/milvus.py", line 598, in add_texts
raise e
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/langchain_community/vectorstores/milvus.py", line 592, in add_texts
res = self.col.insert(insert_list, timeout=timeout, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/orm/collection.py", line 500, in insert
return conn.batch_insert(
^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/decorators.py", line 147, in handler
raise e from e
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/decorators.py", line 143, in handler
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/decorators.py", line 182, in handler
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/decorators.py", line 122, in handler
raise e from e
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/decorators.py", line 87, in handler
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/grpc_handler.py", line 575, in batch_insert
raise err from err
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/grpc_handler.py", line 558, in batch_insert
request = self._prepare_batch_insert_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/grpc_handler.py", line 542, in _prepare_batch_insert_request
else Prepare.batch_insert_param(collection_name, entities, partition_name, fields_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/prepare.py", line 531, in batch_insert_param
return cls._parse_batch_request(request, entities, fields_info, location)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/prepare.py", line 507, in _parse_batch_request
field_data = entity_helper.entity_to_field_data(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/entity_helper.py", line 374, in entity_to_field_data
entity_to_str_arr(entity, field_info, CHECK_STR_ARRAY)
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/entity_helper.py", line 236, in entity_to_str_arr
return convert_to_str_array(entity.get("values", []), field_info, check=check)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/entity_helper.py", line 231, in convert_to_str_array
check_str_arr(arr, max_len)
File "/home/zwm/miniconda3/envs/Langchain-Chatchat2/lib/python3.11/site-packages/pymilvus/client/entity_helper.py", line 214, in check_str_arr
raise ParamError(message=f"expect string input, got: {type(s)}")
pymilvus.exceptions.ParamError: <ParamError: (code=1, message=expect string input, got: <class 'int'>)>
在初始化数据库报的错误。

@zmwstu zmwstu added the bug Something isn't working label May 13, 2024
Copy link

dosubot bot commented May 13, 2024

The error you're encountering, "ParamError: (code=1, message=expect string input, got: <class 'int'>)", indicates that Milvus expects string inputs for certain fields or parameters, but is receiving integers instead. This typically happens during batch insert operations where document IDs or other metadata are not correctly formatted as strings.

To fix this issue, ensure that all parameters expected to be strings by Milvus are indeed strings. This includes document IDs, metadata, and any other fields that might be implicitly expected to be strings. You can do this by explicitly converting these values to strings before they are passed to the add_documents method or any other Milvus operation. For example:

for doc in docs:
    for k, v in doc.metadata.items():
        doc.metadata[k] = str(v)

This snippet converts all metadata values to strings, which should help avoid the type error. Make sure that all fields, especially those that Milvus expects to be strings, are converted accordingly before insertion.

If the error persists after ensuring all inputs are correctly typed as strings, double-check the data being passed into the add_documents method or any related operations to confirm it meets Milvus's expected type requirements.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant