chatchat-space / Langchain-Chatchat

Langchain-Chatchat(原Langchain-ChatGLM)基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain
Apache License 2.0
32.04k stars 5.57k forks source link

[BUG] 用文件对话功能报错AttributeError: 'NoneType' object has no attribute 'get' #4215

Closed wll0307 closed 4 months ago

wll0307 commented 4 months ago

INFO: 127.0.0.1:49410 - "POST /knowledge_base/upload_temp_docs HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application AttributeError: 'NoneType' object has no attribute 'conjugate'

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

Traceback (most recent call last): File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 399, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/applications.py", line 119, in call await self.middleware_stack(scope, receive, send) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call raise exc File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call await self.app(scope, receive, _send) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/routing.py", line 762, in call await self.middleware_stack(scope, receive, send) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/routing.py", line 782, in app await route.handle(scope, receive, send) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/routing.py", line 297, in handle await self.app(scope, receive, send) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/routing.py", line 77, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/routing.py", line 72, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/fastapi/routing.py", line 299, in app raise e File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/fastapi/routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/fastapi/routing.py", line 193, in run_endpoint_function return await run_in_threadpool(dependant.call, values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/starlette/concurrency.py", line 40, in run_in_threadpool return await anyio.to_thread.run_sync(func, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 859, in run result = context.run(func, args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/Langchain-Chatchat/server/chat/file_chat.py", line 87, in upload_temp_docs with memo_faiss_pool.load_vector_store(id).acquire() as vs: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/Langchain-Chatchat/server/knowledge_base/kb_cache/faiss_cache.py", line 129, in load_vector_store vector_store = self.new_vector_store(embed_model=embed_model, embed_device=embed_device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/Langchain-Chatchat/server/knowledge_base/kb_cache/faiss_cache.py", line 60, in new_vector_store vector_store = FAISS.from_documents([doc], embeddings, distance_strategy="METRIC_INNER_PRODUCT") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/langchain_core/vectorstores.py", line 508, in from_documents return cls.from_texts(texts, embedding, metadatas=metadatas, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/langchain_community/vectorstores/faiss.py", line 959, in from_texts embeddings = embedding.embed_documents(texts) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/Langchain-Chatchat/server/knowledge_base/kb_service/base.py", line 439, in embed_documents return normalize(embeddings).tolist() ^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/Langchain-Chatchat/server/knowledge_base/kb_service/base.py", line 37, in normalize norm = np.linalg.norm(embeddings, axis=1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<__array_function__ internals>", line 200, in norm File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/numpy/linalg/linalg.py", line 2541, in norm s = (x.conj() * x).real ^^^^^^^^ TypeError: loop of ufunc does not support argument 0 of type NoneType which has no callable conjugate method 2024-06-19 16:50:04,554 - _client.py[line:1027] - INFO: HTTP Request: POST http://127.0.0.1:7861/knowledge_base/upload_temp_docs "HTTP/1.1 500 Internal Server Error" 2024-06-19 16:50:04.555 Uncaught app exception Traceback (most recent call last): File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py", line 87, in get entry_bytes = self._read_from_mem_cache(key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py", line 137, in _read_from_mem_cache raise CacheStorageKeyNotFoundError("Key not found in mem cache") streamlit.runtime.caching.storage.cache_storage_protocol.CacheStorageKeyNotFoundError: Key not found in mem cache

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_data_api.py", line 634, in read_result pickled_entry = self.storage.get(key) ^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py", line 89, in get entry_bytes = self._persist_storage.get(key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/storage/local_disk_cache_storage.py", line 155, in get raise CacheStorageKeyNotFoundError( streamlit.runtime.caching.storage.cache_storage_protocol.CacheStorageKeyNotFoundError: Local disk cache storage is disabled (persist=None)

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

Traceback (most recent call last): File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 264, in _get_or_create_cached_value cached_result = cache.read_result(value_key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_data_api.py", line 636, in read_result raise CacheKeyNotFoundError(str(e)) from e streamlit.runtime.caching.cache_errors.CacheKeyNotFoundError: Local disk cache storage is disabled (persist=None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py", line 87, in get entry_bytes = self._read_from_mem_cache(key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py", line 137, in _read_from_mem_cache raise CacheStorageKeyNotFoundError("Key not found in mem cache") streamlit.runtime.caching.storage.cache_storage_protocol.CacheStorageKeyNotFoundError: Key not found in mem cache

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_data_api.py", line 634, in read_result pickled_entry = self.storage.get(key) ^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/storage/in_memory_cache_storage_wrapper.py", line 89, in get entry_bytes = self._persist_storage.get(key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/storage/local_disk_cache_storage.py", line 155, in get raise CacheStorageKeyNotFoundError( streamlit.runtime.caching.storage.cache_storage_protocol.CacheStorageKeyNotFoundError: Local disk cache storage is disabled (persist=None)

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

Traceback (most recent call last): File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 312, in _handle_cache_miss cached_result = cache.read_result(value_key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_data_api.py", line 636, in read_result raise CacheKeyNotFoundError(str(e)) from e streamlit.runtime.caching.cache_errors.CacheKeyNotFoundError: Local disk cache storage is disabled (persist=None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script exec(code, module.dict) File "/root/autodl-tmp/Langchain-Chatchat/webui.py", line 64, in pages[selected_page]["func"](api=api, is_lite=is_lite) File "/root/autodl-tmp/Langchain-Chatchat/webui_pages/dialogue/dialogue.py", line 260, in dialogue_page st.session_state["file_chat_id"] = upload_temp_docs(files, api) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 212, in wrapper return cached_func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 241, in call return self._get_or_create_cached_value(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 267, in _get_or_create_cached_value return self._handle_cache_miss(cache, value_key, func_args, func_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/conda/envs/chat/lib/python3.11/site-packages/streamlit/runtime/caching/cache_utils.py", line 321, in _handle_cache_miss computed_value = self._info.func(func_args, **func_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/autodl-tmp/Langchain-Chatchat/webui_pages/dialogue/dialogue.py", line 49, in upload_temp_docs return _api.upload_temp_docs(files).get("data", {}).get("id") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'

SeamanHua commented 4 months ago

是由于模型回答为空导致,检查模型的回复那一块代码

mailtobshen commented 4 months ago

liboffice 未安装问题