From 27ead750c3f036f5fd6ede6b7d0b6ef70ec83567 Mon Sep 17 00:00:00 2001 From: Bruce MacDonald Date: Tue, 4 Jul 2023 11:55:10 -0400 Subject: [PATCH] try next runner if load fails --- ollama/engine.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ollama/engine.py b/ollama/engine.py index db1d51c7..c43033ef 100644 --- a/ollama/engine.py +++ b/ollama/engine.py @@ -39,12 +39,18 @@ def load(model_name, models={}): for model_type in cls.model_types() } - best_match, _ = process.extractOne(model_path, runners.keys()) - model = runners.get(best_match, LlamaCppRunner) + while len(runners) > 0: + try: + best_match, _ = process.extractOne(model_path, runners.keys()) + model = runners.get(best_match, LlamaCppRunner) + runner = model(model_path, best_match) + models.update({model_name: runner}) + return models.get(model_name) + except Exception: + # try the next runner + runners.pop(best_match) - models.update({model_name: model(model_path, best_match)}) - - return models.get(model_name) + raise Exception("failed to load model", model_path, model_name) def unload(model_name, models={}):