From 4392bf26e0a57583388f0b5a06034c630e83a104 Mon Sep 17 00:00:00 2001 From: Cebtenzzre Date: Tue, 26 Sep 2023 09:29:51 -0400 Subject: [PATCH] pyllmodel: print specific error message --- gpt4all-bindings/python/gpt4all/pyllmodel.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gpt4all-bindings/python/gpt4all/pyllmodel.py b/gpt4all-bindings/python/gpt4all/pyllmodel.py index b2842bde..648e5dd6 100644 --- a/gpt4all-bindings/python/gpt4all/pyllmodel.py +++ b/gpt4all-bindings/python/gpt4all/pyllmodel.py @@ -259,12 +259,13 @@ class LLModel: True if model loaded successfully, False otherwise """ model_path_enc = model_path.encode("utf-8") - self.model = llmodel.llmodel_model_create(model_path_enc) + err = LLModelError() + self.model = llmodel.llmodel_model_create2(model_path_enc, b"auto", ctypes.byref(err)) - if self.model is not None: - llmodel.llmodel_loadModel(self.model, model_path_enc) - else: - raise ValueError("Unable to instantiate model") + if self.model is None: + raise ValueError(f"Unable to instantiate model: code={err.code}, {err.message.decode()}") + + llmodel.llmodel_loadModel(self.model, model_path_enc) filename = os.path.basename(model_path) self.model_name = os.path.splitext(filename)[0]