From 0e866a0e8fc5461a906f8dcd29f5a644fd06d3c7 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Wed, 26 Jul 2023 22:06:16 -0500 Subject: [PATCH] Refactor(typescript)/error handling (#1283) * actually display error if it occurs while instantiating * bump version --- gpt4all-bindings/typescript/index.cc | 11 +++++++---- gpt4all-bindings/typescript/package.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gpt4all-bindings/typescript/index.cc b/gpt4all-bindings/typescript/index.cc index e15a5674..457a595c 100644 --- a/gpt4all-bindings/typescript/index.cc +++ b/gpt4all-bindings/typescript/index.cc @@ -58,10 +58,13 @@ Napi::Function NodeModelWrapper::GetClass(Napi::Env env) { } } llmodel_set_implementation_search_path(library_path.c_str()); - llmodel_error* e = nullptr; - inference_ = std::make_shared(llmodel_model_create2(full_weight_path.c_str(), "auto", e)); - if(e != nullptr) { - Napi::Error::New(env, e->message).ThrowAsJavaScriptException(); + llmodel_error e = { + .message="looks good to me", + .code=0, + }; + inference_ = std::make_shared(llmodel_model_create2(full_weight_path.c_str(), "auto", &e)); + if(e.code != 0) { + Napi::Error::New(env, e.message).ThrowAsJavaScriptException(); return; } if(GetInference() == nullptr) { diff --git a/gpt4all-bindings/typescript/package.json b/gpt4all-bindings/typescript/package.json index 42ca51be..90cf828e 100644 --- a/gpt4all-bindings/typescript/package.json +++ b/gpt4all-bindings/typescript/package.json @@ -1,6 +1,6 @@ { "name": "gpt4all", - "version": "2.1.0-alpha", + "version": "2.1.1-alpha", "packageManager": "yarn@3.6.1", "main": "src/gpt4all.js", "repository": "nomic-ai/gpt4all",