react-brai 1.1.0 → 1.1.1

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.

Potentially problematic release.


This version of react-brai might be problematic. Click here for more details.

package/dist/index.d.mts CHANGED
@@ -21,7 +21,9 @@ type WorkerPayload = {
21
21
 
22
22
  declare function useLocalAI(): {
23
23
  isSupported: boolean | null;
24
- loadModel: (modelId: string) => void;
24
+ loadModel: (modelId: string, options?: {
25
+ contextWindow?: number;
26
+ }) => void;
25
27
  chat: (messages: Message[]) => void;
26
28
  isReady: boolean;
27
29
  isLoading: boolean;
package/dist/index.d.ts CHANGED
@@ -21,7 +21,9 @@ type WorkerPayload = {
21
21
 
22
22
  declare function useLocalAI(): {
23
23
  isSupported: boolean | null;
24
- loadModel: (modelId: string) => void;
24
+ loadModel: (modelId: string, options?: {
25
+ contextWindow?: number;
26
+ }) => void;
25
27
  chat: (messages: Message[]) => void;
26
28
  isReady: boolean;
27
29
  isLoading: boolean;
package/dist/index.js CHANGED
@@ -78,11 +78,17 @@ function useLocalAI() {
78
78
  URL.revokeObjectURL(workerUrl);
79
79
  };
80
80
  }, []);
81
- const loadModel = (0, import_react.useCallback)((modelId) => {
82
- console.log("~~~ Loading Model:", modelId);
81
+ const loadModel = (0, import_react.useCallback)((modelId, options) => {
82
+ console.log("~~~ Loading Model:", modelId, "Options:", options);
83
83
  if (!workerRef.current) return;
84
84
  setError(null);
85
- workerRef.current.postMessage({ type: "LOAD", modelId });
85
+ workerRef.current.postMessage({
86
+ type: "LOAD",
87
+ modelId,
88
+ options: {
89
+ context_window_size: options == null ? void 0 : options.contextWindow
90
+ }
91
+ });
86
92
  }, []);
87
93
  const chat = (0, import_react.useCallback)((messages) => {
88
94
  if (!workerRef.current) return;
package/dist/index.mjs CHANGED
@@ -52,11 +52,17 @@ function useLocalAI() {
52
52
  URL.revokeObjectURL(workerUrl);
53
53
  };
54
54
  }, []);
55
- const loadModel = useCallback((modelId) => {
56
- console.log("~~~ Loading Model:", modelId);
55
+ const loadModel = useCallback((modelId, options) => {
56
+ console.log("~~~ Loading Model:", modelId, "Options:", options);
57
57
  if (!workerRef.current) return;
58
58
  setError(null);
59
- workerRef.current.postMessage({ type: "LOAD", modelId });
59
+ workerRef.current.postMessage({
60
+ type: "LOAD",
61
+ modelId,
62
+ options: {
63
+ context_window_size: options == null ? void 0 : options.contextWindow
64
+ }
65
+ });
60
66
  }, []);
61
67
  const chat = useCallback((messages) => {
62
68
  if (!workerRef.current) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-brai",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
package/src/useLocalAI.ts CHANGED
@@ -66,11 +66,20 @@ export function useLocalAI() {
66
66
  };
67
67
  }, []);
68
68
 
69
- const loadModel = useCallback((modelId: string) => {
70
- console.log("~~~ Loading Model:", modelId);
69
+ const loadModel = useCallback((modelId: string, options?: { contextWindow?: number }) => {
70
+ console.log("~~~ Loading Model:", modelId, "Options:", options);
71
+
71
72
  if (!workerRef.current) return;
72
73
  setError(null);
73
- workerRef.current.postMessage({ type: "LOAD", modelId });
74
+
75
+ // We construct the payload to match what the worker expects
76
+ workerRef.current.postMessage({
77
+ type: "LOAD",
78
+ modelId,
79
+ options: {
80
+ context_window_size: options?.contextWindow
81
+ }
82
+ });
74
83
  }, []);
75
84
 
76
85
  const chat = useCallback((messages: Message[]) => {