Skip to content

Commit a5baa8b

Browse files
committed
Update docker-compose files and test endpoints
Update to llama.cpp python: bump bindings version for AMD fixes update llama.cpp-mainline vulkan support for typescript bindings, gguf support (nomic-ai#1390) * adding some native methods to cpp wrapper * gpu seems to work * typings and add availibleGpus method * fix spelling * fix syntax * more * normalize methods to conform to py * remove extra dynamic linker deps when building with vulkan * bump python version (library linking fix) * Don't link against libvulkan. * vulkan python bindings on windows fixes * Bring the vulkan backend to the GUI. * When device is Auto (the default) then we will only consider discrete GPU's otherwise fallback to CPU. * Show the device we're currently using. * Fix up the name and formatting. * init at most one vulkan device, submodule update fixes issues w/ multiple of the same gpu * Update the submodule. * Add version 2.4.15 and bump the version number. * Fix a bug where we're not properly falling back to CPU. * Sync to a newer version of llama.cpp with bugfix for vulkan. * Report the actual device we're using. * Only show GPU when we're actually using it. * Bump to new llama with new bugfix. * Release notes for v2.4.16 and bump the version. * Fallback to CPU more robustly. * Release notes for v2.4.17 and bump the version. * Bump the Python version to python-v1.0.12 to restrict the quants that vulkan recognizes. * Link against ggml in bin so we can get the available devices without loading a model. * Send actual and requested device info for those who have opt-in. * Actually bump the version. * Release notes for v2.4.18 and bump the version. * Fix for crashes on systems where vulkan is not installed properly. * Release notes for v2.4.19 and bump the version. * fix typings and vulkan build works on win * Add flatpak manifest * Remove unnecessary stuffs from manifest * Update to 2.4.19 * appdata: update software description * Latest rebase on llama.cpp with gguf support. * macos build fixes * llamamodel: metal supports all quantization types now * gpt4all.py: GGUF * pyllmodel: print specific error message * backend: port BERT to GGUF * backend: port MPT to GGUF * backend: port Replit to GGUF * backend: use gguf branch of llama.cpp-mainline * backend: use llamamodel.cpp for StarCoder * conversion scripts: cleanup * convert scripts: load model as late as possible * convert_mpt_hf_to_gguf.py: better tokenizer decoding * backend: use llamamodel.cpp for Falcon * convert scripts: make them directly executable * fix references to removed model types * modellist: fix the system prompt * backend: port GPT-J to GGUF * gpt-j: update inference to match latest llama.cpp insights - Use F16 KV cache - Store transposed V in the cache - Avoid unnecessary Q copy Co-authored-by: Georgi Gerganov <[email protected]> ggml upstream commit 0265f0813492602fec0e1159fe61de1bf0ccaf78 * chatllm: grammar fix * convert scripts: use bytes_to_unicode from transformers * convert scripts: make gptj script executable * convert scripts: add feed-forward length for better compatiblilty This GGUF key is used by all llama.cpp models with upstream support. * gptj: remove unused variables * Refactor for subgroups on mat * vec kernel. * Add q6_k kernels for vulkan. * python binding: print debug message to stderr * Fix regenerate button to be deterministic and bump the llama version to latest we have for gguf. * Bump to the latest fixes for vulkan in llama. * llamamodel: fix static vector in LLamaModel::endTokens * Switch to new models2.json for new gguf release and bump our version to 2.5.0. * Bump to latest llama/gguf branch. * chat: report reason for fallback to CPU * chat: make sure to clear fallback reason on success * more accurate fallback descriptions * differentiate between init failure and unsupported models * backend: do not use Vulkan with non-LLaMA models * Add q8_0 kernels to kompute shaders and bump to latest llama/gguf. * backend: fix build with Visual Studio generator Use the $<CONFIG> generator expression instead of CMAKE_BUILD_TYPE. This is needed because Visual Studio is a multi-configuration generator, so we do not know what the build type will be until `cmake --build` is called. Fixes nomic-ai#1470 * remove old llama.cpp submodules * Reorder and refresh our models2.json. * rebase on newer llama.cpp * python/embed4all: use gguf model, allow passing kwargs/overriding model * Add starcoder, rift and sbert to our models2.json. * Push a new version number for llmodel backend now that it is based on gguf. * fix stray comma in models2.json Signed-off-by: Aaron Miller <[email protected]> * Speculative fix for build on mac. * chat: clearer CPU fallback messages * Fix crasher with an empty string for prompt template. * Update the language here to avoid misunderstanding. * added EM German Mistral Model * make codespell happy * issue template: remove "Related Components" section * cmake: install the GPT-J plugin (nomic-ai#1487) * Do not delete saved chats if we fail to serialize properly. * Restore state from text if necessary. * Another codespell attempted fix. * llmodel: do not call magic_match unless build variant is correct (nomic-ai#1488) * chatllm: do not write uninitialized data to stream (nomic-ai#1486) * mat*mat for q4_0, q8_0 * do not process prompts on gpu yet * python: support Path in GPT4All.__init__ (nomic-ai#1462) * llmodel: print an error if the CPU does not support AVX (nomic-ai#1499) * python bindings should be quiet by default * disable llama.cpp logging unless GPT4ALL_VERBOSE_LLAMACPP envvar is nonempty * make verbose flag for retrieve_model default false (but also be overridable via gpt4all constructor) should be able to run a basic test: ```python import gpt4all model = gpt4all.GPT4All('/Users/aaron/Downloads/rift-coder-v0-7b-q4_0.gguf') print(model.generate('def fib(n):')) ``` and see no non-model output when successful * python: always check status code of HTTP responses (nomic-ai#1502) * Always save chats to disk, but save them as text by default. This also changes the UI behavior to always open a 'New Chat' and setting it as current instead of setting a restored chat as current. This improves usability by not requiring the user to wait if they want to immediately start chatting. * Update README.md Signed-off-by: umarmnaq <[email protected]> * fix embed4all filename https://discordapp.com/channels/1076964370942267462/1093558720690143283/1161778216462192692 Signed-off-by: Aaron Miller <[email protected]> * Improves Java API signatures maintaining back compatibility * python: replace deprecated pkg_resources with importlib (nomic-ai#1505) * Updated chat wishlist (nomic-ai#1351) * q6k, q4_1 mat*mat * update mini-orca 3b to gguf2, license Signed-off-by: Aaron Miller <[email protected]> * convert scripts: fix AutoConfig typo (nomic-ai#1512) * publish config https://docs.npmjs.com/cli/v9/configuring-npm/package-json#publishconfig (nomic-ai#1375) merge into my branch * fix appendBin * fix gpu not initializing first * sync up * progress, still wip on destructor * some detection work * untested dispose method * add js side of dispose * Update gpt4all-bindings/typescript/index.cc Co-authored-by: cebtenzzre <[email protected]> Signed-off-by: Jacob Nguyen <[email protected]> * Update gpt4all-bindings/typescript/index.cc Co-authored-by: cebtenzzre <[email protected]> Signed-off-by: Jacob Nguyen <[email protected]> * Update gpt4all-bindings/typescript/index.cc Co-authored-by: cebtenzzre <[email protected]> Signed-off-by: Jacob Nguyen <[email protected]> * Update gpt4all-bindings/typescript/src/gpt4all.d.ts Co-authored-by: cebtenzzre <[email protected]> Signed-off-by: Jacob Nguyen <[email protected]> * Update gpt4all-bindings/typescript/src/gpt4all.js Co-authored-by: cebtenzzre <[email protected]> Signed-off-by: Jacob Nguyen <[email protected]> * Update gpt4all-bindings/typescript/src/util.js Co-authored-by: cebtenzzre <[email protected]> Signed-off-by: Jacob Nguyen <[email protected]> * fix tests * fix circleci for nodejs * bump version --------- Signed-off-by: Aaron Miller <[email protected]> Signed-off-by: umarmnaq <[email protected]> Signed-off-by: Jacob Nguyen <[email protected]> Co-authored-by: Aaron Miller <[email protected]> Co-authored-by: Adam Treat <[email protected]> Co-authored-by: Akarshan Biswas <[email protected]> Co-authored-by: Cebtenzzre <[email protected]> Co-authored-by: Jan Philipp Harries <[email protected]> Co-authored-by: umarmnaq <[email protected]> Co-authored-by: Alex Soto <[email protected]> Co-authored-by: niansa/tuxifan <[email protected]> ts/tooling (nomic-ai#1602) Updated readme for correct install instructions (nomic-ai#1607) Co-authored-by: aj-gameon <[email protected]> llmodel_c: improve quality of error messages (nomic-ai#1625) Add .gguf files to .gitignore and remove unused Dockerfile argument and app/__init__.py file Delete gpt4all-api/gpt4all_api/app/api_v1/routes/__init__.py Signed-off-by: Daniel Salvatierra <[email protected]> Delete gpt4all-api/test.py Signed-off-by: Daniel Salvatierra <[email protected]> Delete gpt4all-api/completiontest.py Signed-off-by: Daniel Salvatierra <[email protected]> Revert "Delete gpt4all-api/completiontest.py" This reverts commit 08e8eea. Revert "Delete gpt4all-api/test.py" This reverts commit 7de26be. Delete test files for local LLM development Refactor code for improved readability and performance. Delete gpt4all-api/completiontest.py Signed-off-by: Daniel Salvatierra <[email protected]> Delete gpt4all-api/test.py Signed-off-by: Daniel Salvatierra <[email protected]> Refactor code for improved readability and performance. Resolve Delete test batched completion function with OpenAI API.
1 parent bc88271 commit a5baa8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6032
-4438
lines changed

.circleci/continue_config.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ jobs:
856856
- node/install-packages:
857857
app-dir: gpt4all-bindings/typescript
858858
pkg-manager: yarn
859+
override-ci-command: yarn install
859860
- run:
860861
command: |
861862
cd gpt4all-bindings/typescript
@@ -885,6 +886,7 @@ jobs:
885886
- node/install-packages:
886887
app-dir: gpt4all-bindings/typescript
887888
pkg-manager: yarn
889+
override-ci-command: yarn install
888890
- run:
889891
command: |
890892
cd gpt4all-bindings/typescript
@@ -994,7 +996,7 @@ jobs:
994996
command: |
995997
cd gpt4all-bindings/typescript
996998
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
997-
npm publish --access public --tag alpha
999+
npm publish
9981000
9991001
workflows:
10001002
version: 2

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,7 @@ build_*
183183
build-*
184184

185185
# IntelliJ
186-
.idea/
186+
.idea/
187+
188+
# gguf files
189+
*.gguf

gpt4all-api/docker-compose.gpu.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ services:
88
environment:
99
- HUGGING_FACE_HUB_TOKEN=token
1010
- USE_FLASH_ATTENTION=false
11-
- MODEL_ID=''
11+
- MODEL_ID=${EMBEDDING}
1212
- NUM_SHARD=1
13+
env_file:
14+
- ./gpt4all_api/.env
1315
command: --model-id $MODEL_ID --num-shard $NUM_SHARD
1416
volumes:
1517
- ./:/data

gpt4all-api/docker-compose.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ services:
77
restart: always #restart on error (usually code compilation from save during bad state)
88
ports:
99
- "4891:4891"
10+
env_file:
11+
- './gpt4all_api/.env'
1012
environment:
1113
- APP_ENVIRONMENT=dev
1214
- WEB_CONCURRENCY=2
1315
- LOGLEVEL=debug
1416
- PORT=4891
15-
- model=ggml-mpt-7b-chat.bin
17+
- model=${MODEL_BIN}
1618
- inference_mode=cpu
1719
volumes:
1820
- './gpt4all_api/app:/app'
21+
- './gpt4all_api/models:/models'
1922
command: ["/start-reload.sh"]

gpt4all-api/gpt4all.code-workspace

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"folders": [
3+
{
4+
"path": ".."
5+
}
6+
]
7+
}

gpt4all-api/gpt4all_api/Dockerfile.buildkit

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# syntax=docker/dockerfile:1.0.0-experimental
22
FROM tiangolo/uvicorn-gunicorn:python3.11
33

4-
ARG MODEL_BIN=ggml-mpt-7b-chat.bin
5-
64
# Put first so anytime this file changes other cached layers are invalidated.
75
COPY gpt4all_api/requirements.txt /requirements.txt
86

gpt4all-api/gpt4all_api/app/__init__.py

Whitespace-only changes.

gpt4all-api/gpt4all_api/app/api_v1/__init__.py

Whitespace-only changes.

gpt4all-api/gpt4all_api/app/api_v1/routes/__init__.py

Whitespace-only changes.

gpt4all-api/gpt4all_api/app/tests/test_endpoints.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,34 @@
22
Use the OpenAI python API to test gpt4all models.
33
"""
44
from typing import List, get_args
5+
import os
6+
from dotenv import load_dotenv
57

68
import openai
79

810
openai.api_base = "http://localhost:4891/v1"
9-
1011
openai.api_key = "not needed for a local LLM"
1112

13+
# Load the .env file
14+
env_path = 'gpt4all-api/gpt4all_api/.env'
15+
load_dotenv(dotenv_path=env_path)
16+
17+
# Fetch MODEL_ID from .env file
18+
model_id = os.getenv('MODEL_BIN', 'default_model_id')
19+
embedding = os.getenv('EMBEDDING', 'default_embedding_model_id')
20+
print (model_id)
21+
print (embedding)
1222

1323
def test_completion():
14-
model = "ggml-mpt-7b-chat.bin"
24+
model = model_id
1525
prompt = "Who is Michael Jordan?"
1626
response = openai.Completion.create(
1727
model=model, prompt=prompt, max_tokens=50, temperature=0.28, top_p=0.95, n=1, echo=True, stream=False
1828
)
1929
assert len(response['choices'][0]['text']) > len(prompt)
2030

2131
def test_streaming_completion():
22-
model = "ggml-mpt-7b-chat.bin"
32+
model = model_id
2333
prompt = "Who is Michael Jordan?"
2434
tokens = []
2535
for resp in openai.Completion.create(
@@ -38,7 +48,7 @@ def test_streaming_completion():
3848

3949

4050
def test_batched_completion():
41-
model = "ggml-mpt-7b-chat.bin"
51+
model = model_id
4252
prompt = "Who is Michael Jordan?"
4353
response = openai.Completion.create(
4454
model=model, prompt=[prompt] * 3, max_tokens=50, temperature=0.28, top_p=0.95, n=1, echo=True, stream=False
@@ -48,12 +58,12 @@ def test_batched_completion():
4858

4959

5060
def test_embedding():
51-
model = "ggml-all-MiniLM-L6-v2-f16.bin"
61+
model = embedding
5262
prompt = "Who is Michael Jordan?"
5363
response = openai.Embedding.create(model=model, input=prompt)
5464
output = response["data"][0]["embedding"]
5565
args = get_args(List[float])
5666

5767
assert response["model"] == model
5868
assert isinstance(output, list)
59-
assert all(isinstance(x, args) for x in output)
69+
assert all(isinstance(x, args) for x in output)
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Place your gguf models and embeddings on this folder

gpt4all-api/makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ clean_testenv:
2828
fresh_testenv: clean_testenv testenv
2929

3030
venv:
31-
if [ ! -d $(ROOT_DIR)/env ]; then $(PYTHON) -m venv $(ROOT_DIR)/env; fi
31+
if [ ! -d $(ROOT_DIR)/venv ]; then $(PYTHON) -m venv $(ROOT_DIR)/venv; fi
3232

3333
dependencies: venv
34-
source $(ROOT_DIR)/env/bin/activate; $(PYTHON) -m pip install -r $(ROOT_DIR)/$(APP_NAME)/requirements.txt
34+
source $(ROOT_DIR)/venv/bin/activate; $(PYTHON) -m pip install -r $(ROOT_DIR)/$(APP_NAME)/requirements.txt
3535

3636
clean: clean_testenv
3737
# Remove existing environment
38-
rm -rf $(ROOT_DIR)/env;
38+
rm -rf $(ROOT_DIR)/venv;
3939
rm -rf $(ROOT_DIR)/$(APP_NAME)/*.pyc;
4040

4141

4242
black:
43-
source $(ROOT_DIR)/env/bin/activate; black -l 120 -S --target-version py38 $(APP_NAME)
43+
source $(ROOT_DIR)/venv/bin/activate; black -l 120 -S --target-version py38 $(APP_NAME)
4444

4545
isort:
46-
source $(ROOT_DIR)/env/bin/activate; isort --ignore-whitespace --atomic -w 120 $(APP_NAME)
46+
source $(ROOT_DIR)/venv/bin/activate; isort --ignore-whitespace --atomic -w 120 $(APP_NAME)

gpt4all-backend/llamamodel.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -385,22 +385,35 @@ DLL_EXPORT const char *get_build_variant() {
385385
}
386386

387387
DLL_EXPORT bool magic_match(const char * fname) {
388-
389388
struct ggml_context * ctx_meta = NULL;
390389
struct gguf_init_params params = {
391390
/*.no_alloc = */ true,
392391
/*.ctx = */ &ctx_meta,
393392
};
394393
gguf_context *ctx_gguf = gguf_init_from_file(fname, params);
395-
if (!ctx_gguf)
394+
if (!ctx_gguf) {
395+
std::cerr << __func__ << ": gguf_init_from_file failed\n";
396396
return false;
397+
}
398+
399+
bool valid = true;
400+
401+
int gguf_ver = gguf_get_version(ctx_gguf);
402+
if (valid && gguf_ver > 3) {
403+
std::cerr << __func__ << ": unsupported gguf version: " << gguf_ver << "\n";
404+
valid = false;
405+
}
397406

398-
bool isValid = gguf_get_version(ctx_gguf) <= 3;
399407
auto arch = get_arch_name(ctx_gguf);
400-
isValid = isValid && (arch == "llama" || arch == "starcoder" || arch == "falcon" || arch == "mpt");
408+
if (valid && !(arch == "llama" || arch == "starcoder" || arch == "falcon" || arch == "mpt")) {
409+
if (!(arch == "gptj" || arch == "bert")) { // we support these via other modules
410+
std::cerr << __func__ << ": unsupported model architecture: " << arch << "\n";
411+
}
412+
valid = false;
413+
}
401414

402415
gguf_free(ctx_gguf);
403-
return isValid;
416+
return valid;
404417
}
405418

406419
DLL_EXPORT LLModel *construct() {

gpt4all-backend/llmodel.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,18 @@ const std::vector<LLModel::Implementation> &LLModel::Implementation::implementat
123123
}
124124

125125
const LLModel::Implementation* LLModel::Implementation::implementation(const char *fname, const std::string& buildVariant) {
126+
bool buildVariantMatched = false;
126127
for (const auto& i : implementationList()) {
127128
if (buildVariant != i.m_buildVariant) continue;
129+
buildVariantMatched = true;
130+
128131
if (!i.m_magicMatch(fname)) continue;
129132
return &i;
130133
}
134+
135+
if (!buildVariantMatched) {
136+
std::cerr << "LLModel ERROR: Could not find any implementations for build variant: " << buildVariant << "\n";
137+
}
131138
return nullptr;
132139
}
133140

gpt4all-backend/llmodel_c.cpp

+8-20
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,33 @@ struct LLModelWrapper {
1111
~LLModelWrapper() { delete llModel; }
1212
};
1313

14-
1514
thread_local static std::string last_error_message;
1615

17-
1816
llmodel_model llmodel_model_create(const char *model_path) {
19-
auto fres = llmodel_model_create2(model_path, "auto", nullptr);
17+
const char *error;
18+
auto fres = llmodel_model_create2(model_path, "auto", &error);
2019
if (!fres) {
21-
fprintf(stderr, "Invalid model file\n");
20+
fprintf(stderr, "Unable to instantiate model: %s\n", error);
2221
}
2322
return fres;
2423
}
2524

26-
llmodel_model llmodel_model_create2(const char *model_path, const char *build_variant, llmodel_error *error) {
25+
llmodel_model llmodel_model_create2(const char *model_path, const char *build_variant, const char **error) {
2726
auto wrapper = new LLModelWrapper;
28-
int error_code = 0;
2927

3028
try {
3129
wrapper->llModel = LLModel::Implementation::construct(model_path, build_variant);
30+
if (!wrapper->llModel) {
31+
last_error_message = "Model format not supported (no matching implementation found)";
32+
}
3233
} catch (const std::exception& e) {
33-
error_code = EINVAL;
3434
last_error_message = e.what();
3535
}
3636

3737
if (!wrapper->llModel) {
3838
delete std::exchange(wrapper, nullptr);
39-
// Get errno and error message if none
40-
if (error_code == 0) {
41-
if (errno != 0) {
42-
error_code = errno;
43-
last_error_message = std::strerror(error_code);
44-
} else {
45-
error_code = ENOTSUP;
46-
last_error_message = "Model format not supported (no matching implementation found)";
47-
}
48-
}
49-
// Set error argument
5039
if (error) {
51-
error->message = last_error_message.c_str();
52-
error->code = error_code;
40+
*error = last_error_message.c_str();
5341
}
5442
}
5543
return reinterpret_cast<llmodel_model*>(wrapper);

gpt4all-backend/llmodel_c.h

+2-13
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ extern "C" {
2323
*/
2424
typedef void *llmodel_model;
2525

26-
/**
27-
* Structure containing any errors that may eventually occur
28-
*/
29-
struct llmodel_error {
30-
const char *message; // Human readable error description; Thread-local; guaranteed to survive until next llmodel C API call
31-
int code; // errno; 0 if none
32-
};
33-
#ifndef __cplusplus
34-
typedef struct llmodel_error llmodel_error;
35-
#endif
36-
3726
/**
3827
* llmodel_prompt_context structure for holding the prompt context.
3928
* NOTE: The implementation takes care of all the memory handling of the raw logits pointer and the
@@ -105,10 +94,10 @@ DEPRECATED llmodel_model llmodel_model_create(const char *model_path);
10594
* Recognises correct model type from file at model_path
10695
* @param model_path A string representing the path to the model file; will only be used to detect model type.
10796
* @param build_variant A string representing the implementation to use (auto, default, avxonly, ...),
108-
* @param error A pointer to a llmodel_error; will only be set on error.
97+
* @param error A pointer to a string; will only be set on error.
10998
* @return A pointer to the llmodel_model instance; NULL on error.
11099
*/
111-
llmodel_model llmodel_model_create2(const char *model_path, const char *build_variant, llmodel_error *error);
100+
llmodel_model llmodel_model_create2(const char *model_path, const char *build_variant, const char **error);
112101

113102
/**
114103
* Destroy a llmodel instance.

gpt4all-bindings/golang/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ $(info I CXX: $(CXXV))
139139
$(info )
140140

141141
llmodel.o:
142-
mkdir buildllm
142+
[ -e buildllm ] || mkdir buildllm
143143
cd buildllm && cmake ../../../gpt4all-backend/ $(CMAKEFLAGS) && make
144144
cd buildllm && cp -rf CMakeFiles/llmodel.dir/llmodel_c.cpp.o ../llmodel_c.o
145145
cd buildllm && cp -rf CMakeFiles/llmodel.dir/llmodel.cpp.o ../llmodel.o
@@ -150,7 +150,7 @@ clean:
150150
rm -rf buildllm
151151
rm -rf example/main
152152

153-
binding.o:
153+
binding.o: binding.cpp binding.h
154154
$(CXX) $(CXXFLAGS) binding.cpp -o binding.o -c $(LDFLAGS)
155155

156156
libgpt4all.a: binding.o llmodel.o

gpt4all-bindings/golang/binding.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
void* load_model(const char *fname, int n_threads) {
1919
// load the model
20-
llmodel_error new_error{};
20+
const char *new_error;
2121
auto model = llmodel_model_create2(fname, "auto", &new_error);
22-
if (model == nullptr ){
23-
fprintf(stderr, "%s: error '%s'\n",
24-
__func__, new_error.message);
22+
if (model == nullptr) {
23+
fprintf(stderr, "%s: error '%s'\n", __func__, new_error);
2524
return nullptr;
2625
}
2726
if (!llmodel_loadModel(model, fname)) {

gpt4all-bindings/golang/placeholder

Whitespace-only changes.

gpt4all-bindings/java/src/main/java/com/hexadevlabs/gpt4all/LLModel.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.hexadevlabs.gpt4all;
22

33
import jnr.ffi.Pointer;
4+
import jnr.ffi.byref.PointerByReference;
45
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
67

@@ -176,7 +177,7 @@ public LLModel(Path modelPath) {
176177
modelName = modelPath.getFileName().toString();
177178
String modelPathAbs = modelPath.toAbsolutePath().toString();
178179

179-
LLModelLibrary.LLModelError error = new LLModelLibrary.LLModelError(jnr.ffi.Runtime.getSystemRuntime());
180+
PointerByReference error = new PointerByReference();
180181

181182
// Check if model file exists
182183
if(!Files.exists(modelPath)){
@@ -192,7 +193,7 @@ public LLModel(Path modelPath) {
192193
model = library.llmodel_model_create2(modelPathAbs, "auto", error);
193194

194195
if(model == null) {
195-
throw new IllegalStateException("Could not load, gpt4all backend returned error: " + error.message);
196+
throw new IllegalStateException("Could not load, gpt4all backend returned error: " + error.getValue().getString(0));
196197
}
197198
library.llmodel_loadModel(model, modelPathAbs);
198199

@@ -631,4 +632,4 @@ public void close() throws Exception {
631632
library.llmodel_model_destroy(model);
632633
}
633634

634-
}
635+
}

0 commit comments

Comments
 (0)