uniteai icon indicating copy to clipboard operation
uniteai copied to clipboard

uniteai_llm does not run

Open nickworks opened this issue 1 year ago • 4 comments

Hello, after installing with pip3 install --user "uniteai[all]" I try to run uniteai_llm, but receive the following error:

Traceback (most recent call last):
  File "/Users/nick/.local/bin/uniteai_llm", line 5, in <module>
    from uniteai.llm_server import main
  File "/Users/nick/.local/lib/python3.11/site-packages/uniteai/llm_server.py", line 99, in <module>
    args = config['local_llm']
           ~~~~~~^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Is there something I'm doing wrong? Thanks!

Mac OS X 14.1.1 /Users/nick/.local/bin/uniteai_llm /Users/nick/.local/bin/uniteai_lsp

nickworks avatar Dec 01 '23 20:12 nickworks

For some reason it sounds like you don't have a uniteai.yml file.

If you have added uniteai to your editor, upon first running it should create this file and ask you to restart your editor. I'm still trying to make this process smoother, so thanks for the bug report.

The file is copied from: https://github.com/freckletonj/uniteai/blob/master/uniteai/.uniteai.yml.example#L95

And the LSP looks in these locations for it, in this order:

    './.uniteai.yml',
    './.uniteai.yaml',
    os.path.expanduser('~/.uniteai.yml'),
    os.path.expanduser('~/.uniteai.yaml'),

So, I'd say try running it in the editor first, and allowing it to create the file for you.

Or copy it to one of those locations.

freckletonj avatar Dec 01 '23 23:12 freckletonj

Thanks for the reply! Here are some follow-up steps I just tried.

  1. Uninstalled, then reinstalled the VS Code uniteai extension.
  2. Manually created ~/.uniteai.yml (using the linked file contents above) and restarted VS Code.
  3. Renamed the file above (just in case), trying the names: ~/uniteai.yml, ~/.uniteai.yml, ~/.uniteai.yaml

Each time, VS Code has an error in the UniteAI output:

Traceback (most recent call last):
  File "/Users/nick/.local/bin/uniteai_lsp", line 5, in <module>
    from uniteai.lsp_server import main
  File "/Users/nick/.local/lib/python3.11/site-packages/uniteai/lsp_server.py", line 69, in <module>
    logging.basicConfig(
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 2050, in basicConfig
    h = FileHandler(filename, mode,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/log_file.log'
[Error - 8:21:21 AM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 8:21:21 AM] Connection to server got closed. Server will restart.
true
[Error - 8:21:21 AM] UniteAI client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Traceback (most recent call last):
  File "/Users/nick/.local/bin/uniteai_lsp", line 5, in <module>
    from uniteai.lsp_server import main
  File "/Users/nick/.local/lib/python3.11/site-packages/uniteai/lsp_server.py", line 69, in <module>
    logging.basicConfig(
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 2050, in basicConfig
    h = FileHandler(filename, mode,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/log_file.log'
[Error - 8:21:22 AM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 8:21:22 AM] Connection to server got closed. Server will restart.
true
[Error - 8:21:22 AM] UniteAI client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Traceback (most recent call last):
  File "/Users/nick/.local/bin/uniteai_lsp", line 5, in <module>
    from uniteai.lsp_server import main
  File "/Users/nick/.local/lib/python3.11/site-packages/uniteai/lsp_server.py", line 69, in <module>
    logging.basicConfig(
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 2050, in basicConfig
    h = FileHandler(filename, mode,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/log_file.log'
[Error - 8:21:22 AM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 8:21:22 AM] Connection to server got closed. Server will restart.
true
[Error - 8:21:22 AM] UniteAI client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 8:21:22 AM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Traceback (most recent call last):
  File "/Users/nick/.local/bin/uniteai_lsp", line 5, in <module>
    from uniteai.lsp_server import main
  File "/Users/nick/.local/lib/python3.11/site-packages/uniteai/lsp_server.py", line 69, in <module>
    logging.basicConfig(
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 2050, in basicConfig
    h = FileHandler(filename, mode,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/log_file.log'
[Error - 8:21:22 AM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 8:21:22 AM] Connection to server got closed. Server will restart.
true
[Error - 8:21:22 AM] UniteAI client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 8:21:22 AM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Traceback (most recent call last):
  File "/Users/nick/.local/bin/uniteai_lsp", line 5, in <module>
    from uniteai.lsp_server import main
  File "/Users/nick/.local/lib/python3.11/site-packages/uniteai/lsp_server.py", line 69, in <module>
    logging.basicConfig(
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 2050, in basicConfig
    h = FileHandler(filename, mode,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/Users/nick/anaconda3/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 30] Read-only file system: '/log_file.log'
[Error - 8:21:23 AM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 8:21:23 AM] The UniteAI server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 8:21:23 AM] UniteAI client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 8:21:23 AM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 

Looks like a possible file permissions issue with log_file.log?

nickworks avatar Dec 04 '23 13:12 nickworks

It looks like it's trying to create that log file, but your system is read-only:

OSError: [Errno 30] Read-only file system: '/log_file.log'

Is your file system read-only? Or, I can't quite tell, it might be trying to make that file at root /, which I have no idea why it would default there.

Here's the relevant line of code: https://github.com/freckletonj/uniteai/blob/master/uniteai/lsp_server.py#L70

Oh, are you running lsp_server from your root directory? That's where it's trying to put the file. Try going into some user directory where it will have permissions to create it.

I'm happy to help you keep debugging if that doesn't work. It helps me to robustify this!

freckletonj avatar Dec 04 '23 18:12 freckletonj

For some reason it sounds like you don't have a uniteai.yml file.

If you have added uniteai to your editor, upon first running it should create this file and ask you to restart your editor. I'm still trying to make this process smoother, so thanks for the bug report.

The file is copied from: https://github.com/freckletonj/uniteai/blob/master/uniteai/.uniteai.yml.example#L95

And the LSP looks in these locations for it, in this order:

    './.uniteai.yml',
    './.uniteai.yaml',
    os.path.expanduser('~/.uniteai.yml'),
    os.path.expanduser('~/.uniteai.yaml'),

So, I'd say try running it in the editor first, and allowing it to create the file for you.

Or copy it to one of those locations.

When installing in a venv, this file is also missing. (and the emacs setup doesn't seem to have code to create it)

hrehfeld avatar Sep 08 '24 18:09 hrehfeld