Langchain-Chatchat icon indicating copy to clipboard operation
Langchain-Chatchat copied to clipboard

[BUG] milvus向量库上传文档报错

Open jiyang2024 opened this issue 11 months ago • 3 comments

milvus可以进行知识库文档,但是向milvus上传新的文档报错信息如下:

INFO: 127.0.0.1:57820 - "POST /knowledge_base/search_docs HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/encoders.py", line 322, in jsonable_encoder data = dict(obj) TypeError: 'numpy.float32' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/encoders.py", line 327, in jsonable_encoder data = vars(obj) TypeError: vars() argument must have dict attribute

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi result = await app( # type: ignore[func-returns-value] File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call return await self.app(scope, receive, send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/applications.py", line 119, in call await self.middleware_stack(scope, receive, send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/routing.py", line 762, in call await self.middleware_stack(scope, receive, send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/routing.py", line 782, in app await route.handle(scope, receive, send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/routing.py", line 297, in handle await self.app(scope, receive, send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/routing.py", line 77, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/starlette/routing.py", line 72, in app response = await func(request) File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/routing.py", line 315, in app content = await serialize_response( File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/routing.py", line 170, in serialize_response return jsonable_encoder( File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/encoders.py", line 301, in jsonable_encoder jsonable_encoder( File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/encoders.py", line 235, in jsonable_encoder return jsonable_encoder( File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/encoders.py", line 287, in jsonable_encoder encoded_value = jsonable_encoder( File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/encoders.py", line 287, in jsonable_encoder encoded_value = jsonable_encoder( File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/encoders.py", line 301, in jsonable_encoder jsonable_encoder( File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/fastapi/encoders.py", line 330, in jsonable_encoder raise ValueError(errors) from e ValueError: [TypeError("'numpy.float32' object is not iterable"), TypeError('vars() argument must have dict attribute')] 2024-03-06 05:35:13,656 - _client.py[line:1027] - INFO: HTTP Request: POST http://127.0.0.1:7861/knowledge_base/search_docs "HTTP/1.1 500 Internal Server Error" 2024-03-06 05:35:13.658 Uncaught app exception Traceback (most recent call last): File "/root/anaconda3/envs/env_rag/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script exec(code, module.dict) File "/root/jgy/Langchain-Chatchat/webui.py", line 64, in pages[selected_page]["func"](api=api, is_lite=is_lite) File "/root/jgy/Langchain-Chatchat/webui_pages/knowledge_base/knowledge_base.py", line 328, in knowledge_base_page data = [ File "/root/jgy/Langchain-Chatchat/webui_pages/knowledge_base/knowledge_base.py", line 329, in {"seq": i + 1, "id": x["id"], "page_content": x["page_content"], "source": x["metadata"].get("source"), TypeError: string indices must be integers

jiyang2024 avatar Mar 06 '24 05:03 jiyang2024

嘿 @jiyang2024,又见面啦!希望这次我们能一起搞定这个棘手的问题。👾

根据您提供的错误信息,问题出在尝试将numpy.float32对象转换为可迭代对象时。这可能是因为在处理数据时,某个应该是列表或字典的变量被错误地赋值为了numpy.float32对象。

knowledge_base_page函数中,x变量应该是一个字典,其中包含了知识库中的文档信息。错误信息显示在尝试访问x["id"]x["page_content"]x["metadata"].get("source")时,x变量是一个字符串,这就是为什么会出现TypeError: string indices must be integers的错误。

我在Langchain-Chatchat的问题跟踪中找到了一个类似的问题:自定义知识库 上传、删除等报错。这个问题的建议解决方案是更新项目代码和依赖项(特别是langchain/fschat),然后再试一次。

如果更新代码和依赖项后问题仍然存在,那么可能需要进一步检查knowledge_base_page函数中处理x变量的代码,确保在处理数据时不会将x错误地赋值为numpy.float32对象。

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.

If you want to continue the conversation, start your reply with @dosu-bot.

dosubot[bot] avatar Mar 06 '24 05:03 dosubot[bot]

请问这个问题解决了吗,我也遇到了同样的问题

HuntZhaozq avatar Mar 12 '24 02:03 HuntZhaozq

@dosu-bot

zcs007 avatar Mar 12 '24 03:03 zcs007

这个问题已经被标记为 stale ,因为它已经超过 30 天没有任何活动。

github-actions[bot] avatar Jun 19 '24 21:06 github-actions[bot]

这个问题已经被自动关闭,因为它被标为 stale 后超过 14 天没有任何活动。

github-actions[bot] avatar Jul 03 '24 21:07 github-actions[bot]