cui-llama.rn 1.7.0 → 1.7.2

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.
@@ -107,21 +107,18 @@ public class LlamaContext {
107
107
  }
108
108
 
109
109
  String modelName = params.getString("model");
110
-
111
- if(!isGGUF(modelName, reactContext)) {
112
- throw new IllegalArgumentException("File is not in GGUF format");
113
- }
114
-
115
- if ( modelName.startsWith("content://")) {
116
- Uri uri = Uri.parse(modelName);
110
+
111
+ if (modelName.startsWith("content://")) {
112
+ Uri uri = Uri.parse(modelName);
117
113
  try {
118
114
  ParcelFileDescriptor pfd = reactContext.getApplicationContext().getContentResolver().openFileDescriptor(uri, "r");
119
- modelName = "" + pfd.getFd();
115
+ modelName = "" + pfd.getFd();
120
116
  } catch (Exception e) {
121
117
  Log.e(NAME, "Failed to convert to FD!");
122
118
  }
123
119
  }
124
120
 
121
+
125
122
  // Check if file has GGUF magic numbers
126
123
  this.id = id;
127
124
  eventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
@@ -5,6 +5,8 @@ import android.util.Log;
5
5
  import android.os.Build;
6
6
  import android.os.Handler;
7
7
  import android.os.AsyncTask;
8
+ import android.os.ParcelFileDescriptor;
9
+ import android.net.Uri;
8
10
 
9
11
  import com.facebook.react.bridge.Promise;
10
12
  import com.facebook.react.bridge.ReactApplicationContext;
@@ -15,6 +17,7 @@ import com.facebook.react.bridge.ReadableArray;
15
17
  import com.facebook.react.bridge.WritableMap;
16
18
  import com.facebook.react.bridge.Arguments;
17
19
 
20
+
18
21
  import java.util.HashMap;
19
22
  import java.util.Random;
20
23
  import java.io.File;
@@ -68,10 +71,24 @@ public class RNLlama implements LifecycleEventListener {
68
71
  promise.resolve(null);
69
72
  }
70
73
 
74
+ private String getContentFileDescriptor(String modelName) {
75
+ if (!modelName.startsWith("content://")) return modelName;
76
+ Uri uri = Uri.parse(modelName);
77
+ try {
78
+ ParcelFileDescriptor pfd = reactContext.getApplicationContext().getContentResolver().openFileDescriptor(uri, "r");
79
+ return "" + pfd.getFd();
80
+ } catch (Exception e) {
81
+ Log.e(NAME, "Failed to convert to FD!");
82
+ }
83
+ return modelName;
84
+ }
85
+
71
86
  public void modelInfo(final String model, final ReadableArray skip, final Promise promise) {
87
+ final String modelPath = getContentFileDescriptor(model);
88
+
72
89
  new AsyncTask<Void, Void, WritableMap>() {
73
90
  private Exception exception;
74
-
91
+
75
92
  @Override
76
93
  protected WritableMap doInBackground(Void... voids) {
77
94
  try {
@@ -79,7 +96,7 @@ public class RNLlama implements LifecycleEventListener {
79
96
  for (int i = 0; i < skip.size(); i++) {
80
97
  skipArray[i] = skip.getString(i);
81
98
  }
82
- return LlamaContext.modelInfo(model, skipArray);
99
+ return LlamaContext.modelInfo(modelPath, skipArray);
83
100
  } catch (Exception e) {
84
101
  exception = e;
85
102
  }
package/cpp/common.cpp CHANGED
@@ -1112,9 +1112,6 @@ struct llama_model_params common_model_params_to_llama(common_params & params) {
1112
1112
  mparams.tensor_buft_overrides = params.tensor_buft_overrides.data();
1113
1113
  }
1114
1114
 
1115
- mparams.progress_callback = params.load_progress_callback;
1116
- mparams.progress_callback_user_data = params.load_progress_callback_user_data;
1117
-
1118
1115
  return mparams;
1119
1116
  }
1120
1117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cui-llama.rn",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "Fork of llama.rn for ChatterUI",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",