cui-llama.rn 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,7 +69,11 @@ public class LlamaContext {
|
|
69
69
|
try {
|
70
70
|
if (filepath.startsWith("content")) {
|
71
71
|
Uri uri = Uri.parse(filepath);
|
72
|
-
|
72
|
+
try {
|
73
|
+
reactContext.getApplicationContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
74
|
+
} catch (SecurityException e) {
|
75
|
+
Log.w(NAME, "Persistable permission not granted for URI: " + uri);
|
76
|
+
}
|
73
77
|
fis = reactContext.getApplicationContext().getContentResolver().openInputStream(uri);
|
74
78
|
} else {
|
75
79
|
fis = new FileInputStream(filepath);
|
@@ -107,7 +111,11 @@ public class LlamaContext {
|
|
107
111
|
}
|
108
112
|
|
109
113
|
String modelName = params.getString("model");
|
110
|
-
|
114
|
+
|
115
|
+
if(!isGGUF(modelName, reactContext)) {
|
116
|
+
throw new IllegalArgumentException("File is not in GGUF format");
|
117
|
+
}
|
118
|
+
|
111
119
|
if (modelName.startsWith("content://")) {
|
112
120
|
Uri uri = Uri.parse(modelName);
|
113
121
|
try {
|
@@ -117,7 +125,6 @@ public class LlamaContext {
|
|
117
125
|
Log.e(NAME, "Failed to convert to FD!");
|
118
126
|
}
|
119
127
|
}
|
120
|
-
|
121
128
|
|
122
129
|
// Check if file has GGUF magic numbers
|
123
130
|
this.id = id;
|
@@ -442,6 +449,11 @@ public class LlamaContext {
|
|
442
449
|
if (mmprojPath == null || mmprojPath.isEmpty()) {
|
443
450
|
throw new IllegalArgumentException("mmproj_path is empty");
|
444
451
|
}
|
452
|
+
|
453
|
+
if(!isGGUF(mmprojPath, this.reactContext)) {
|
454
|
+
throw new IllegalArgumentException("File is not in GGUF format");
|
455
|
+
}
|
456
|
+
|
445
457
|
File file = new File(mmprojPath);
|
446
458
|
if (!mmprojPath.startsWith("content") && !file.exists()) {
|
447
459
|
throw new IllegalArgumentException("mmproj file does not exist: " + mmprojPath);
|
@@ -7,6 +7,7 @@ import android.os.Handler;
|
|
7
7
|
import android.os.AsyncTask;
|
8
8
|
import android.os.ParcelFileDescriptor;
|
9
9
|
import android.net.Uri;
|
10
|
+
import android.content.Intent;
|
10
11
|
|
11
12
|
import com.facebook.react.bridge.Promise;
|
12
13
|
import com.facebook.react.bridge.ReactApplicationContext;
|
@@ -85,6 +86,15 @@ public class RNLlama implements LifecycleEventListener {
|
|
85
86
|
|
86
87
|
public void modelInfo(final String model, final ReadableArray skip, final Promise promise) {
|
87
88
|
final String modelPath = getContentFileDescriptor(model);
|
89
|
+
|
90
|
+
if (model.startsWith("content")) {
|
91
|
+
Uri uri = Uri.parse(model);
|
92
|
+
try {
|
93
|
+
reactContext.getApplicationContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
94
|
+
} catch (SecurityException e) {
|
95
|
+
Log.w(NAME, "Persistable permission not granted for URI: " + uri);
|
96
|
+
}
|
97
|
+
}
|
88
98
|
|
89
99
|
new AsyncTask<Void, Void, WritableMap>() {
|
90
100
|
private Exception exception;
|