Skip to content

"ilab chat" temp server crashes on ctrl+C during response #883

@leseb

Description

@leseb

See:

(venv) [leseb@tarox~/cli/test_run_RNR30OPb][fix-sigint-on-temp-server] ilab chat
DEBUG 2024-04-17 09:44:02,214 server.py:62 Trying to connect to http://127.0.0.1:8000/v1...
DEBUG 2024-04-17 09:44:05,196 server.py:77 Trying port 43275...
DEBUG 2024-04-17 09:44:05,196 server.py:97 Port 43275 is available.
DEBUG 2024-04-17 09:44:05,196 server.py:101 Connection to http://127.0.0.1:8000/v1 failed. Starting a temporary server at http://127.0.0.1:43275/v1...
╭────────────────────────────────────────────────────────── system ──────────────────────────────────────────────────────────╮
│ Welcome to Chat CLI w/ MERLINITE-7B-Q4_K_M (type /h for help)                                                              │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
>>> hello                                                                                                         [S][default]
╭─────────────────────────────────────────────────── merlinite-7b-Q4_K_M ────────────────────────────────────────────────────╮
╭─────────────────────────────────────────────────── merlinite-7b-Q4_K_M ────────────────────────────────────────────────────╮
│ Hello! How can I                                                                                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────── elapsed 0.684 seconds ─╯
>>> disconnected                                                                                                  [S][default]
Disconnected from client (via refresh/close) Address(host='127.0.0.1', port=36076)
Process Process-1:
Traceback (most recent call last):
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
    yield
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpx/_transports/default.py", line 233, in handle_request
    resp = self._pool.handle_request(req)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
    raise exc from None
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
    response = connection.handle_request(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpcore/_sync/connection.py", line 122, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpcore/_backends/sync.py", line 205, in connect_tcp
    with map_exceptions(exc_map):
  File "/usr/lib64/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [Errno 111] Connection refused

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

Traceback (most recent call last):
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 951, in _request
    response = self._client.send(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpx/_client.py", line 914, in send
    response = self._send_handling_auth(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpx/_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpx/_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpx/_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpx/_transports/default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "/usr/lib64/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 111] Connection refused

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

Traceback (most recent call last):
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/cli/client.py", line 36, in list_models
    return client.models.list()
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/resources/models.py", line 79, in list
    return self._get_api_list(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 1282, in get_api_list
    return self._request_api_list(model, page, opts)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 1127, in _request_api_list
    return self.request(page, options, stream=False)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 922, in request
    return self._request(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 975, in _request
    return self._retry_request(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 1046, in _retry_request
    return self._request(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 975, in _request
    return self._retry_request(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 1046, in _retry_request
    return self._request(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/openai/_base_client.py", line 985, in _request
    raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.

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

Traceback (most recent call last):
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/cli/server.py", line 63, in ensure_server
    list_models(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/cli/client.py", line 38, in list_models
    raise ClientException(f"Connection Error {exc}") from exc
cli.client.ClientException: Connection Error Connection error.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib64/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/cli/server.py", line 188, in server
    uvicorn.run(
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/uvicorn/main.py", line 575, in run
    server.run()
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/lib64/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 600, in run_forever
    self._run_once()
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 1896, in _run_once
    handle._run()
  File "/usr/lib64/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/uvicorn/server.py", line 68, in serve
    with self.capture_signals():
  File "/usr/lib64/python3.10/contextlib.py", line 142, in __exit__
    next(self.gen)
  File "/home/leseb/cli/test_run_RNR30OPb/venv/lib64/python3.10/site-packages/uvicorn/server.py", line 328, in capture_signals
    signal.raise_signal(captured_signal)
KeyboardInterrupt
>>>                                                                                                               [S][default]
>>> hello                                                                                                         [S][default]
Connection error, try again...
>>>                             

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions