llm icon indicating copy to clipboard operation
llm copied to clipboard

Error on first use: `Foreign key already exists for chat_id => log.id`

Open chadparker opened this issue 3 months ago • 0 comments

I'm getting this error on a fresh install, and I'm not sure what's causing it:

$ llm "hello"

Hello! How can I assist you today?
Traceback (most recent call last):
  File "/opt/homebrew/bin/llm", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm/cli.py", line 291, in prompt
    migrate(db)
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm/migrations.py", line 14, in migrate
    fn(db)
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/llm/migrations.py", line 61, in m003_chat_id_foreign_key
    db["log"].add_foreign_key("chat_id", "log", "id")
  File "/opt/homebrew/Cellar/llm/0.13.1/libexec/lib/python3.12/site-packages/sqlite_utils/db.py", line 2302, in add_foreign_key
    raise AlterError(
sqlite_utils.db.AlterError: Foreign key already exists for chat_id => log.id

I installed via brew install llm, after doing brew update and brew upgrade.

I would love some help solving this!

chadparker avatar Apr 01 '24 15:04 chadparker