@forbocai/browser 0.5.1 → 0.5.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.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CortexConfig, ICortex, MemoryType, MemoryItem, MemoryConfig } from '@forbocai/core';
2
2
 
3
- declare const createBrowserCortex: (config: CortexConfig) => ICortex;
4
- declare const createCortex: (config: CortexConfig) => ICortex;
3
+ declare const createBrowserCortex: (config?: CortexConfig) => ICortex;
4
+ declare const createCortex: (config?: CortexConfig) => ICortex;
5
5
 
6
6
  interface IBrowserMemory {
7
7
  store(text: string, type?: MemoryType, importance?: number): Promise<MemoryItem>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CortexConfig, ICortex, MemoryType, MemoryItem, MemoryConfig } from '@forbocai/core';
2
2
 
3
- declare const createBrowserCortex: (config: CortexConfig) => ICortex;
4
- declare const createCortex: (config: CortexConfig) => ICortex;
3
+ declare const createBrowserCortex: (config?: CortexConfig) => ICortex;
4
+ declare const createCortex: (config?: CortexConfig) => ICortex;
5
5
 
6
6
  interface IBrowserMemory {
7
7
  store(text: string, type?: MemoryType, importance?: number): Promise<MemoryItem>;
package/dist/index.js CHANGED
@@ -42,11 +42,20 @@ module.exports = __toCommonJS(index_exports);
42
42
  // src/cortex.ts
43
43
  var import_web_llm = require("@mlc-ai/web-llm");
44
44
  var import_meta = {};
45
- var createBrowserCortex = (config) => {
45
+ var DEFAULT_MODEL = "smollm2-135m";
46
+ var MODEL_ALIASES = {
47
+ "smollm2-135m": "SmolLM2-135M-Instruct-q4f16_1-MLC",
48
+ "smollm2-360m": "SmolLM2-360M-Instruct-q4f16_1-MLC",
49
+ "smollm2-1.7b": "SmolLM2-1.7B-Instruct-q4f16_1-MLC",
50
+ "llama3-8b": "Llama-3.1-8B-Instruct-q4f16_1-MLC"
51
+ };
52
+ var resolveModelId = (alias) => MODEL_ALIASES[alias] ?? alias;
53
+ var createBrowserCortex = (config = {}) => {
54
+ const friendlyModel = config.model || DEFAULT_MODEL;
46
55
  let engine = null;
47
56
  let status = {
48
57
  id: "browser-init",
49
- model: config.model || "smollm2-135m",
58
+ model: friendlyModel,
50
59
  ready: false,
51
60
  engine: "web-llm"
52
61
  };
@@ -57,7 +66,7 @@ var createBrowserCortex = (config) => {
57
66
  if (onProgress) {
58
67
  }
59
68
  };
60
- const modelId = config.model || "SmolLM2-135M-Instruct-q4f16_1-MLC";
69
+ const modelId = resolveModelId(friendlyModel);
61
70
  engine = await (0, import_web_llm.CreateWebWorkerMLCEngine)(
62
71
  new Worker(new URL("./worker.js", import_meta.url), { type: "module" }),
63
72
  modelId,
@@ -99,7 +108,7 @@ var createBrowserCortex = (config) => {
99
108
  completeStream
100
109
  };
101
110
  };
102
- var createCortex = (config) => createBrowserCortex(config);
111
+ var createCortex = (config = {}) => createBrowserCortex(config);
103
112
 
104
113
  // src/memory.ts
105
114
  var import_orama = require("@orama/orama");
package/dist/index.mjs CHANGED
@@ -1,10 +1,19 @@
1
1
  // src/cortex.ts
2
2
  import { CreateWebWorkerMLCEngine } from "@mlc-ai/web-llm";
3
- var createBrowserCortex = (config) => {
3
+ var DEFAULT_MODEL = "smollm2-135m";
4
+ var MODEL_ALIASES = {
5
+ "smollm2-135m": "SmolLM2-135M-Instruct-q4f16_1-MLC",
6
+ "smollm2-360m": "SmolLM2-360M-Instruct-q4f16_1-MLC",
7
+ "smollm2-1.7b": "SmolLM2-1.7B-Instruct-q4f16_1-MLC",
8
+ "llama3-8b": "Llama-3.1-8B-Instruct-q4f16_1-MLC"
9
+ };
10
+ var resolveModelId = (alias) => MODEL_ALIASES[alias] ?? alias;
11
+ var createBrowserCortex = (config = {}) => {
12
+ const friendlyModel = config.model || DEFAULT_MODEL;
4
13
  let engine = null;
5
14
  let status = {
6
15
  id: "browser-init",
7
- model: config.model || "smollm2-135m",
16
+ model: friendlyModel,
8
17
  ready: false,
9
18
  engine: "web-llm"
10
19
  };
@@ -15,7 +24,7 @@ var createBrowserCortex = (config) => {
15
24
  if (onProgress) {
16
25
  }
17
26
  };
18
- const modelId = config.model || "SmolLM2-135M-Instruct-q4f16_1-MLC";
27
+ const modelId = resolveModelId(friendlyModel);
19
28
  engine = await CreateWebWorkerMLCEngine(
20
29
  new Worker(new URL("./worker.js", import.meta.url), { type: "module" }),
21
30
  modelId,
@@ -57,7 +66,7 @@ var createBrowserCortex = (config) => {
57
66
  completeStream
58
67
  };
59
68
  };
60
- var createCortex = (config) => createBrowserCortex(config);
69
+ var createCortex = (config = {}) => createBrowserCortex(config);
61
70
 
62
71
  // src/memory.ts
63
72
  import { create, insert, search } from "@orama/orama";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forbocai/browser",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Web Browser implementation for ForbocAI SDK",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "test": "vitest"
13
13
  },
14
14
  "dependencies": {
15
- "@forbocai/core": "^0.5.1",
15
+ "@forbocai/core": "^0.5.2",
16
16
  "@mlc-ai/web-llm": "^0.2.46",
17
17
  "@orama/orama": "^2.0.26",
18
18
  "@huggingface/transformers": "^3.0.0"