simonw/llm-replicate

KeyError: 'id' in version 0.2

Closed this issue · 1 comments

Hi,

I don't understand why the latest version on pypi is 0.2 but the latest on github is 0.3.

I've been getting issues when trying this plugin today. The error was at this line in init.py because a details["latest_version"] has no "id" key.

This ended up blocking the whole llm app (the crash would occur for example for llm models, llm aliases etc.) Trying to use openai's API failed too as long as the plugin was installed.

I have llm --version 0.11 and tried llm-replicate version 0.2.

To me this indicates at least that the plugins init should be wrapped in a try block to avoid crashing the whole llm package.

Fixed it for my case :

diff --git a/llm_replicate/__init__.py b/llm_replicate/__init__.py
index 78e8ca1..58661b5 100644
--- a/llm_replicate/__init__.py
+++ b/llm_replicate/__init__.py
@@ -193,6 +193,9 @@ def register_models(register):
     if fetch_models_path.exists():
         models = json.loads(fetch_models_path.read_text())
         for details in models:
+            if not details["latest_version"]:
+                print(f"Skipping model '{details['name']}'")
+                continue
             register(
                 ReplicateModel(
                     owner=details["owner"],

Then doing llm models will show Skipping model without version: replit-code-v1-3b then the list of other models.

I'll do a quick PR right now but my version is 0.2 and not 0.3 so I don't know if that's still relevant.