react-brai 1.0.4 → 1.1.0
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 +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +108 -0
- package/dist/index.mjs +81 -0
- package/package.json +1 -1
- package/src/types.ts +11 -5
- package/src/worker-embedded.ts +1 -1
- package/src/worker.ts +12 -2
package/src/worker.ts
CHANGED
|
@@ -6,12 +6,22 @@ let engine: MLCEngineInterface | null = null;
|
|
|
6
6
|
|
|
7
7
|
// Listen for messages from the Main Thread (React)
|
|
8
8
|
self.onmessage = async (e: MessageEvent<WorkerPayload>) => {
|
|
9
|
-
|
|
9
|
+
// 1. Destructure 'options' from the incoming message
|
|
10
|
+
const { type, modelId, messages, options } = e.data;
|
|
10
11
|
|
|
11
12
|
try {
|
|
12
|
-
// 1. Load the Model
|
|
13
13
|
if (type === "LOAD" && modelId) {
|
|
14
|
+
// 2. Prepare the config object
|
|
15
|
+
// We use the user's requested limit, or default to standard 4k if undefined
|
|
16
|
+
const appConfig = options?.context_window_size
|
|
17
|
+
? { context_window_size: options.context_window_size } as any // <--- ADD 'as any' HERE
|
|
18
|
+
: undefined;
|
|
19
|
+
|
|
20
|
+
console.log(`[Worker] Loading model with context: ${appConfig?.context_window_size || 'Default (4096)'}`);
|
|
21
|
+
|
|
22
|
+
// 3. Pass appConfig to the engine
|
|
14
23
|
engine = await CreateMLCEngine(modelId, {
|
|
24
|
+
appConfig: appConfig, // <--- THIS UNLOCKS THE LIMIT
|
|
15
25
|
initProgressCallback: (report) => {
|
|
16
26
|
postMsg({ type: "PROGRESS", payload: report });
|
|
17
27
|
},
|