mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-11-04 16:11:30 +00:00
Java binding - Improve error check before loading Model file (#1206)
* Javav binding - Add check for Model file be Readable. * add todo for java binding. --------- Co-authored-by: Feliks Zaslavskiy <feliks.zaslavskiy@optum.com> Co-authored-by: felix <felix@zaslavskiy.net>
This commit is contained in:
@@ -184,11 +184,16 @@ public class LLModel implements AutoCloseable {
|
||||
throw new IllegalStateException("Model file does not exist: " + modelPathAbs);
|
||||
}
|
||||
|
||||
// Check if file is Readable
|
||||
if(!Files.isReadable(modelPath)){
|
||||
throw new IllegalStateException("Model file cannot be read: " + modelPathAbs);
|
||||
}
|
||||
|
||||
// Create Model Struct. Will load dynamically the correct backend based on model type
|
||||
model = library.llmodel_model_create2(modelPathAbs, "auto", error);
|
||||
|
||||
if(model == null) {
|
||||
throw new IllegalStateException("Could not load gpt4all backend :" + error.message);
|
||||
throw new IllegalStateException("Could not load, gpt4all backend returned error: " + error.message);
|
||||
}
|
||||
library.llmodel_loadModel(model, modelPathAbs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user