Langchain-Chatchat
Langchain-Chatchat copied to clipboard
[BUG] milvus向量库上传文档报错
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
嘿 @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
-
[BUG] 简洁阐述问题 / Concise description of the issueTraceback (most recent call last): File "/data/soft/anaconda3/envs/langchain/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script exec(code, module.dict) File "/data/chenhui/text_similarity_main/Langchain-Chatchat/webui.py", line 64, in
pages[selected_page]["func"](api=api, is_lite=is_lite) File "/data/chenhui/text_similarity_main/Langchain-Chatchat/webui_pages/dialogue/dialogue.py", line 163, in dialogue_page running_models = list(api.list_running_models()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not iterable 报错的原因,给我正确的答案 - 运行报错
- 自定义知识库 上传、删除等报错
- webui_pages/knowledge_base/knowledge_base.py
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.
请问这个问题解决了吗,我也遇到了同样的问题
@dosu-bot
这个问题已经被标记为 stale
,因为它已经超过 30 天没有任何活动。
这个问题已经被自动关闭,因为它被标为 stale
后超过 14 天没有任何活动。