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

[BUG] 简洁ERROR: RemoteProtocolError: API通信遇到错误:peer closed connection without sending complete message body (incomplete chunked read)阐述问题 / Concise description of the issue #3750

Open
A-runaaaa opened this issue Apr 15, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@A-runaaaa
Copy link

一键运行之后 使用LLM对话都没有问题 但是使用知识库问答 和文件对话时都会报一个“创建History对象时content属性的值为None而引起的错误。根据错误信息,似乎content属性不允许为None。可能需要检查代码中创建History对象的地方,并确保在创建对象时提供了有效的content值,下面是具体的报错信息。具体应该修改哪些地方的内容
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
| await super().call(scope, receive, send)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/applications.py", line 119, in call
| await self.middleware_stack(scope, receive, send)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call
| raise exc
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call
| await self.app(scope, receive, _send)
| File "/home/guanjr/miniconda3/envs/KQAP/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 "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
| raise exc
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
| await app(scope, receive, sender)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/routing.py", line 762, in call
| await self.middleware_stack(scope, receive, send)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/routing.py", line 782, in app
| await route.handle(scope, receive, send)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/routing.py", line 297, in handle
| await self.app(scope, receive, send)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/routing.py", line 77, in app
| await wrap_app_handling_exceptions(app, request)(scope, receive, send)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
| raise exc
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
| await app(scope, receive, sender)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/starlette/routing.py", line 75, in app
| await response(scope, receive, send)
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/sse_starlette/sse.py", line 255, in call
| async with anyio.create_task_group() as task_group:
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 678, in aexit
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/sse_starlette/sse.py", line 258, in wrap
| await func()
| File "/home/guanjr/miniconda3/envs/KQAP/lib/python3.11/site-packages/sse_starlette/sse.py", line 245, in stream_response
| async for data in self.body_iterator:
| File "/home/guanjr/Langchain-Chatchat-master_2024_2/server/chat/file_chat.py", line 138, in knowledge_base_chat_iterator
| input_msg = History(role="user", content=prompt_template).to_msg_template(False)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init
| pydantic.error_wrappers.ValidationError: 1 validation error for History
| content
| none is not an allowed value (type=type_error.none.not_allowed)

@A-runaaaa A-runaaaa added the bug Something isn't working label Apr 15, 2024
Copy link

dosubot bot commented Apr 15, 2024

To address the ValidationError for the History object with content being None, ensure prompt_template is not None before creating the History object in the knowledge_base_chat_iterator function within file_chat.py. Here's a quick fix:

if prompt_template is not None:
    input_msg = History(role="user", content=prompt_template).to_msg_template(False)
else:
    # Handle None case, perhaps set a default value or raise an error
    input_msg = History(role="user", content="default value").to_msg_template(False)

For the RemoteProtocolError, it's crucial to ensure network requests are correctly formatted and to handle exceptions properly. Wrap network operations in a try-except block to catch and handle RemoteProtocolError:

try:
    # Replace with your network operation
    response = some_network_operation()
except RemoteProtocolError as e:
    # Log the error and respond appropriately
    logger.error(f"Remote protocol error encountered: {e}")
    raise HTTPException(status_code=500, detail="A remote protocol error occurred")

Implementing these solutions should help resolve the issues you're encountering with the knowledge base Q&A and file dialogue features.

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.

@zRzRzRzRzRzRzR zRzRzRzRzRzRzR self-assigned this May 6, 2024
@zRzRzRzRzRzRzR
Copy link
Collaborator

这是没输入内容吧

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

2 participants