-
Notifications
You must be signed in to change notification settings - Fork 450
fix: gentle error handling on server crash during chat response #614
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
fix: gentle error handling on server crash during chat response #614
Conversation
23d0439 to
1b18054
Compare
|
seems there are more changes than this PR aims for. |
This is intended, can we merge #613 first? |
|
can you resolve the conflicts in #613? |
|
#613 is in now but the merge conflicts here are a bit more complex. |
9b15323 to
f693b66
Compare
I resolved the conflicts and removed the refactoring. |
c467301 to
fa5fdfb
Compare
c583772 to
a819b57
Compare
3cd18dd to
5e26c14
Compare
The chat was abruptly failing with the following stack trace if the chat
is answering and the server crashes during that time:
```
lab chat
╭──────────────────────────────────────────────────────────────────── system ────────────────────────────────────────────────────────────────────╮
│ Welcome to Chat CLI w/ MERLINITE-7B-Q4_K_M (type /h for help) │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
>>> [S][default]
>>> hello [S][default]
╭───────────────────────────────────────────────────────────── merlinite-7b-Q4_K_M ──────────────────────────────────────────────────────────────╮
│ Hello! I'm here to │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── elapsed 1.031 seconds ─╯
Traceback (most recent call last):
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
yield
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpx/_transports/default.py", line 113, in __iter__
for part in self._httpcore_stream:
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 367, in __iter__
raise exc from None
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 363, in __iter__
for part in self._stream:
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpcore/_sync/http11.py", line 349, in __iter__
raise exc
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpcore/_sync/http11.py", line 341, in __iter__
for chunk in self._connection._receive_response_body(**kwargs):
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpcore/_sync/http11.py", line 210, in _receive_response_body
event = self._receive_event(timeout=timeout)
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpcore/_sync/http11.py", line 220, in _receive_event
with map_exceptions({h11.RemoteProtocolError: RemoteProtocolError}):
File "/usr/lib64/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/home/leseb/cli/test_run_2Fv9yrYE/venv/lib64/python3.10/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)
```
Now we handle this more elagantly and print before exiting:
```
lab chat
╭──────────────────────────────────────────────────────────────────── system ────────────────────────────────────────────────────────────────────╮
│ Welcome to Chat CLI w/ MERLINITE-7B-Q4_K_M (type /h for help) │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
>>> hello [S][default]
Connection to the server was closed
Executing chat failed with: API issue found while executing chat: Connection to the server was closed
```
Signed-off-by: Sébastien Han <[email protected]>
xukai92
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks very neat now! thanks!
The chat was abruptly failing with the following stack trace if the chat is answering and the server crashes during that time:
Now we handle this more elagantly and print before exiting:
DO NOT MERGE - DEPENDS ON: #613