@elizaos/plugin-local-ai 2.0.0-alpha.7 → 2.0.0-beta.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.
- package/LICENSE +21 -0
- package/README.md +148 -0
- package/dist/browser/index.browser.js +8 -11
- package/dist/browser/index.browser.js.map +3 -3
- package/dist/build.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.node.cjs +3148 -2542
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/environment.d.ts.map +1 -1
- package/dist/generated/specs/specs.d.ts +1 -18
- package/dist/generated/specs/specs.d.ts.map +1 -1
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/node/index.node.js +410 -454
- package/dist/node/index.node.js.map +13 -12
- package/dist/structured-output.d.ts +60 -0
- package/dist/structured-output.d.ts.map +1 -0
- package/dist/utils/platform.d.ts +1 -0
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/tokenizerManager.d.ts.map +1 -1
- package/dist/utils/transcribeManager.d.ts.map +1 -1
- package/dist/utils/ttsManager.d.ts.map +1 -1
- package/dist/utils/visionManager.d.ts.map +1 -1
- package/dist/utils/xmlParser.d.ts.map +1 -1
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/package.json +22 -23
- package/index.browser.ts +0 -116
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { JSONSchema, ToolDefinition } from "@elizaos/core";
|
|
2
|
+
import { type ChatModelFunctionCall, type ChatSessionModelFunctions, type GbnfJsonSchema, type Llama, LlamaGrammar, LlamaJsonSchemaGrammar } from "node-llama-cpp";
|
|
3
|
+
export interface ToolCallResult {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
arguments: Record<string, unknown>;
|
|
7
|
+
type: "function";
|
|
8
|
+
}
|
|
9
|
+
export interface StructuredOutputContext {
|
|
10
|
+
llama: Llama;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Convert an elizaOS-shaped JSON schema to the Gbnf variant accepted by
|
|
14
|
+
* node-llama-cpp's grammar / function-calling APIs. The two schema dialects
|
|
15
|
+
* overlap heavily — node-llama-cpp tolerates `type: "object"` with
|
|
16
|
+
* `properties` / `required` plus the standard scalar types — so we forward
|
|
17
|
+
* the schema as-is. We narrow the type with a runtime check.
|
|
18
|
+
*/
|
|
19
|
+
export declare function toGbnfJsonSchema(schema: JSONSchema | undefined): GbnfJsonSchema | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Build a `functions` map for `LlamaChatSession.prompt({ functions })` from
|
|
22
|
+
* the elizaOS `ToolDefinition[]` shape. The handler is a no-op: we want the
|
|
23
|
+
* raw call objects back from `promptWithMeta`, not in-loop tool execution.
|
|
24
|
+
* The runtime is responsible for executing the tool and looping back.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildLlamaFunctions(tools: readonly ToolDefinition[]): ChatSessionModelFunctions;
|
|
27
|
+
/**
|
|
28
|
+
* Pull parsed function calls out of a `promptWithMeta` response array.
|
|
29
|
+
* Mirrors the OpenAI/Anthropic provider shape: `{ id, name, arguments }`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function extractToolCalls(response: ReadonlyArray<string | ChatModelFunctionCall | unknown>): ToolCallResult[];
|
|
32
|
+
/**
|
|
33
|
+
* Build a `LlamaJsonSchemaGrammar` for a caller-supplied JSON Schema. The
|
|
34
|
+
* grammar constrains the model's output so it always parses as valid JSON
|
|
35
|
+
* matching the schema.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildJsonSchemaGrammar(llama: Llama, schema: JSONSchema): LlamaJsonSchemaGrammar<GbnfJsonSchema>;
|
|
38
|
+
/**
|
|
39
|
+
* Get the canonical JSON grammar shipped with node-llama-cpp. Used when the
|
|
40
|
+
* caller passes `responseFormat: { type: "json_object" }` without a specific
|
|
41
|
+
* schema — output is constrained to be any valid JSON value.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildGenericJsonGrammar(llama: Llama): Promise<LlamaGrammar>;
|
|
44
|
+
export interface StructuredRequestPlan {
|
|
45
|
+
kind: "text" | "tools" | "schema" | "json_object";
|
|
46
|
+
functions?: ChatSessionModelFunctions;
|
|
47
|
+
grammar?: LlamaGrammar;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Decide which structured-output mode applies to a single generation call.
|
|
51
|
+
* Tools take priority over schema; schema takes priority over generic JSON.
|
|
52
|
+
*/
|
|
53
|
+
export declare function planStructuredRequest(ctx: StructuredOutputContext, params: {
|
|
54
|
+
tools?: readonly ToolDefinition[];
|
|
55
|
+
responseSchema?: JSONSchema;
|
|
56
|
+
responseFormat?: {
|
|
57
|
+
type: "json_object" | "text";
|
|
58
|
+
} | string | undefined;
|
|
59
|
+
}): Promise<StructuredRequestPlan>;
|
|
60
|
+
//# sourceMappingURL=structured-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-output.d.ts","sourceRoot":"","sources":["../structured-output.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAE9B,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,YAAY,EACZ,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,cAAc,GAAG,SAAS,CAM3F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,yBAAyB,CAc/F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,aAAa,CAAC,MAAM,GAAG,qBAAqB,GAAG,OAAO,CAAC,GAChE,cAAc,EAAE,CAmBlB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,UAAU,GACjB,sBAAsB,CAAC,cAAc,CAAC,CAMxC;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CAEjF;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,CAAC;IAClD,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,uBAAuB,EAC5B,MAAM,EAAE;IACN,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAClC,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,cAAc,CAAC,EAAE;QAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,SAAS,CAAC;CACxE,GACA,OAAO,CAAC,qBAAqB,CAAC,CAiBhC"}
|
package/dist/utils/platform.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../utils/platform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../utils/platform.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,GAAG,EAAE,SAAS,CAAC;IACf,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IACtB,oBAAoB,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnD,iBAAiB,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC,CAAC;CACjE;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkB;IACzC,OAAO,CAAC,YAAY,CAAmC;IAEvD,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,eAAe;IAO/B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAUnB,wBAAwB;IAgBtC,OAAO,CAAC,UAAU;YAiBJ,SAAS;YAoBT,YAAY;YA6BZ,mBAAmB;YA6BnB,gBAAgB;YAmChB,cAAc;YA+Bd,sBAAsB;YAWtB,oBAAoB;IA4BlC,OAAO,CAAC,uBAAuB;IAmB/B,eAAe,IAAI,kBAAkB;IAOrC,cAAc,IAAI,OAAO;IAIzB,aAAa,IAAI,OAAO;IAIxB,YAAY,IAAI,OAAO;IAIvB,aAAa,IAAI,OAAO;IAIxB,gBAAgB,IAAI,OAAO;IAI3B,qBAAqB,IAAI,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK;CAY/D;AAED,eAAO,MAAM,kBAAkB,QAAO,eAErC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenizerManager.d.ts","sourceRoot":"","sources":["../../utils/tokenizerManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tokenizerManager.d.ts","sourceRoot":"","sources":["../../utils/tokenizerManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiB,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiC;IACxD,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO;IAMP,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,gBAAgB;IAOnE,aAAa,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA+EnE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyC/D,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAwCxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcribeManager.d.ts","sourceRoot":"","sources":["../../utils/transcribeManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transcribeManager.d.ts","sourceRoot":"","sources":["../../utils/transcribeManager.ts"],"names":[],"mappings":"AA0BA,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkC;IACzD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,iBAAiB,CAAS;IAElC,OAAO;IAYM,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAoBtC,iBAAiB,IAAI,OAAO;IAItB,gBAAgB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAOzC,kBAAkB;YAuBlB,gBAAgB;YAkChB,uBAAuB;YA8BvB,wBAAwB;IAoBtC,OAAO,CAAC,4BAA4B;WAiBtB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB;IAO9D,OAAO,CAAC,oBAAoB;YAMd,YAAY;YA8CZ,eAAe;IAiEhB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAqF3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ttsManager.d.ts","sourceRoot":"","sources":["../../utils/ttsManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ttsManager.d.ts","sourceRoot":"","sources":["../../utils/ttsManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAmDpD,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAClD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,uBAAuB,CAA6B;IAC5D,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,mBAAmB,CAA8B;IAEzD,OAAO;WAMO,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU;IAOvD,OAAO,CAAC,oBAAoB;YAOd,UAAU;IAiFX,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CA8D7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visionManager.d.ts","sourceRoot":"","sources":["../../utils/visionManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"visionManager.d.ts","sourceRoot":"","sources":["../../utils/visionManager.ts"],"names":[],"mappings":"AAiCA,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA8B;IACrD,OAAO,CAAC,KAAK,CAAkD;IAC/D,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,cAAc,CAAiB;IAEvC,OAAO;IASP,OAAO,CAAC,iBAAiB;IA6BzB,OAAO,CAAC,qBAAqB;WAOf,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa;IAO1D,OAAO,CAAC,gBAAgB;YASV,UAAU;YA6IV,UAAU;IAqCX,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CAwE7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xmlParser.d.ts","sourceRoot":"","sources":["../../utils/xmlParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xmlParser.d.ts","sourceRoot":"","sources":["../../utils/xmlParser.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA0D1E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAShD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED,wBAAgB,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAuDlF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQtD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CA6BtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAKG"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-local-ai",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/
|
|
6
|
+
"main": "dist/node/index.node.js",
|
|
7
7
|
"module": "dist/node/index.node.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
|
-
"browser": "index.browser.
|
|
9
|
+
"browser": "dist/browser/index.browser.js",
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -17,14 +17,13 @@
|
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"browser": {
|
|
20
|
-
"types": "./index.d.ts",
|
|
21
|
-
"import": "./index.browser.
|
|
22
|
-
"default": "./index.browser.
|
|
20
|
+
"types": "./dist/browser/index.d.ts",
|
|
21
|
+
"import": "./dist/browser/index.browser.js",
|
|
22
|
+
"default": "./dist/browser/index.browser.js"
|
|
23
23
|
},
|
|
24
24
|
"node": {
|
|
25
25
|
"types": "./dist/node/index.d.ts",
|
|
26
26
|
"import": "./dist/node/index.node.js",
|
|
27
|
-
"require": "./dist/cjs/index.node.cjs",
|
|
28
27
|
"default": "./dist/node/index.node.js"
|
|
29
28
|
},
|
|
30
29
|
"default": "./dist/node/index.node.js"
|
|
@@ -40,7 +39,7 @@
|
|
|
40
39
|
"build": "bun run build.ts",
|
|
41
40
|
"build:ts": "bun run build.ts",
|
|
42
41
|
"dev": "bun --hot build.ts",
|
|
43
|
-
"clean": "rm -rf dist .turbo
|
|
42
|
+
"clean": "rm -rf dist .turbo",
|
|
44
43
|
"test": "vitest run",
|
|
45
44
|
"typecheck": "tsc --noEmit",
|
|
46
45
|
"lint": "bunx @biomejs/biome check --write --unsafe .",
|
|
@@ -49,22 +48,21 @@
|
|
|
49
48
|
"format:check": "bunx @biomejs/biome format ."
|
|
50
49
|
},
|
|
51
50
|
"dependencies": {
|
|
52
|
-
"@elizaos/core": "2.0.0-
|
|
53
|
-
"@huggingface/transformers": "^
|
|
54
|
-
"node-llama-cpp": "3.
|
|
51
|
+
"@elizaos/core": "2.0.0-beta.1",
|
|
52
|
+
"@huggingface/transformers": "^4.0.0",
|
|
53
|
+
"node-llama-cpp": "3.18.1",
|
|
55
54
|
"stream-browserify": "^3.0.0",
|
|
56
|
-
"
|
|
57
|
-
"uuid": "^13.0.0",
|
|
55
|
+
"uuid": "^14.0.0",
|
|
58
56
|
"whisper-node": "^1.1.1",
|
|
59
|
-
"zod": "^4.3
|
|
57
|
+
"zod": "^4.4.3"
|
|
60
58
|
},
|
|
61
59
|
"devDependencies": {
|
|
62
|
-
"@biomejs/biome": "^2.
|
|
60
|
+
"@biomejs/biome": "^2.4.14",
|
|
63
61
|
"@types/node": "^25.0.3",
|
|
64
|
-
"typescript": "^
|
|
62
|
+
"typescript": "^6.0.3"
|
|
65
63
|
},
|
|
66
64
|
"peerDependencies": {
|
|
67
|
-
"@elizaos/core": "2.0.0-
|
|
65
|
+
"@elizaos/core": "2.0.0-beta.1"
|
|
68
66
|
},
|
|
69
67
|
"publishConfig": {
|
|
70
68
|
"access": "public"
|
|
@@ -88,28 +86,28 @@
|
|
|
88
86
|
"type": "string",
|
|
89
87
|
"description": "Filename of the small local AI model.",
|
|
90
88
|
"required": false,
|
|
91
|
-
"default": "
|
|
89
|
+
"default": "text/eliza-1-mobile-1_7b-32k.gguf",
|
|
92
90
|
"sensitive": false
|
|
93
91
|
},
|
|
94
92
|
"LOCAL_LARGE_MODEL": {
|
|
95
93
|
"type": "string",
|
|
96
94
|
"description": "Filename of the large local AI model.",
|
|
97
95
|
"required": false,
|
|
98
|
-
"default": "
|
|
96
|
+
"default": "text/eliza-1-desktop-9b-64k.gguf",
|
|
99
97
|
"sensitive": false
|
|
100
98
|
},
|
|
101
99
|
"LOCAL_EMBEDDING_MODEL": {
|
|
102
100
|
"type": "string",
|
|
103
101
|
"description": "Filename of the embedding model used for vector embeddings.",
|
|
104
102
|
"required": false,
|
|
105
|
-
"default": "
|
|
103
|
+
"default": "text/eliza-1-lite-0_6b-32k.gguf",
|
|
106
104
|
"sensitive": false
|
|
107
105
|
},
|
|
108
106
|
"LOCAL_EMBEDDING_DIMENSIONS": {
|
|
109
107
|
"type": "number",
|
|
110
108
|
"description": "Number of dimensions the embedding model outputs.",
|
|
111
109
|
"required": false,
|
|
112
|
-
"default":
|
|
110
|
+
"default": 1024,
|
|
113
111
|
"sensitive": false
|
|
114
112
|
},
|
|
115
113
|
"CUDA_VISIBLE_DEVICES": {
|
|
@@ -120,7 +118,7 @@
|
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
},
|
|
123
|
-
"
|
|
121
|
+
"eliza": {
|
|
124
122
|
"platforms": [
|
|
125
123
|
"browser",
|
|
126
124
|
"node"
|
|
@@ -130,5 +128,6 @@
|
|
|
130
128
|
"browser": "Browser-compatible build available via exports.browser",
|
|
131
129
|
"node": "Node.js build available via exports.node"
|
|
132
130
|
}
|
|
133
|
-
}
|
|
131
|
+
},
|
|
132
|
+
"gitHead": "401e0d2502fea9d6f459aa80faad1369798e9600"
|
|
134
133
|
}
|
package/index.browser.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
GenerateTextParams,
|
|
3
|
-
IAgentRuntime,
|
|
4
|
-
ImageDescriptionParams,
|
|
5
|
-
ObjectGenerationParams,
|
|
6
|
-
Plugin,
|
|
7
|
-
TextEmbeddingParams,
|
|
8
|
-
} from "@elizaos/core";
|
|
9
|
-
import { logger, ModelType } from "@elizaos/core";
|
|
10
|
-
|
|
11
|
-
// Inline types for browser compatibility (avoid import resolution issues)
|
|
12
|
-
type ImageDescriptionResult = {
|
|
13
|
-
title: string;
|
|
14
|
-
description: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type ImageGenerationResult = {
|
|
18
|
-
url: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const pluginName = "local-ai";
|
|
22
|
-
const unsupportedMessage =
|
|
23
|
-
"Local AI is not supported in browsers. Use a server proxy or switch providers.";
|
|
24
|
-
|
|
25
|
-
const warnUnsupported = (modelType: string): void => {
|
|
26
|
-
logger.warn(`[plugin-${pluginName}] ${modelType} is not available in browsers.`);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const unsupportedText = (modelType: string): string => {
|
|
30
|
-
warnUnsupported(modelType);
|
|
31
|
-
return unsupportedMessage;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const unsupportedObject = (modelType: string): Record<string, string> => {
|
|
35
|
-
warnUnsupported(modelType);
|
|
36
|
-
return { error: unsupportedMessage };
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const unsupportedImageDescription = (modelType: string): ImageDescriptionResult => {
|
|
40
|
-
warnUnsupported(modelType);
|
|
41
|
-
return {
|
|
42
|
-
title: "Unsupported",
|
|
43
|
-
description: unsupportedMessage,
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const localAiPlugin: Plugin = {
|
|
48
|
-
name: pluginName,
|
|
49
|
-
description: "Local AI plugin (browser stub; use a server proxy)",
|
|
50
|
-
async init(_config, _runtime: IAgentRuntime): Promise<void> {
|
|
51
|
-
logger.warn(
|
|
52
|
-
`[plugin-${pluginName}] This plugin is not supported directly in browsers. Use a server proxy.`
|
|
53
|
-
);
|
|
54
|
-
},
|
|
55
|
-
models: {
|
|
56
|
-
[ModelType.TEXT_SMALL]: async (
|
|
57
|
-
_runtime: IAgentRuntime,
|
|
58
|
-
_params: GenerateTextParams
|
|
59
|
-
): Promise<string> => unsupportedText(ModelType.TEXT_SMALL),
|
|
60
|
-
[ModelType.TEXT_LARGE]: async (
|
|
61
|
-
_runtime: IAgentRuntime,
|
|
62
|
-
_params: GenerateTextParams
|
|
63
|
-
): Promise<string> => unsupportedText(ModelType.TEXT_LARGE),
|
|
64
|
-
[ModelType.TEXT_REASONING_SMALL]: async (
|
|
65
|
-
_runtime: IAgentRuntime,
|
|
66
|
-
_params: GenerateTextParams
|
|
67
|
-
): Promise<string> => unsupportedText(ModelType.TEXT_REASONING_SMALL),
|
|
68
|
-
[ModelType.TEXT_REASONING_LARGE]: async (
|
|
69
|
-
_runtime: IAgentRuntime,
|
|
70
|
-
_params: GenerateTextParams
|
|
71
|
-
): Promise<string> => unsupportedText(ModelType.TEXT_REASONING_LARGE),
|
|
72
|
-
[ModelType.TEXT_COMPLETION]: async (
|
|
73
|
-
_runtime: IAgentRuntime,
|
|
74
|
-
_params: GenerateTextParams
|
|
75
|
-
): Promise<string> => unsupportedText(ModelType.TEXT_COMPLETION),
|
|
76
|
-
[ModelType.TEXT_EMBEDDING]: async (
|
|
77
|
-
_runtime: IAgentRuntime,
|
|
78
|
-
_params: TextEmbeddingParams | string | null
|
|
79
|
-
): Promise<number[]> => {
|
|
80
|
-
warnUnsupported(ModelType.TEXT_EMBEDDING);
|
|
81
|
-
return new Array(384).fill(0);
|
|
82
|
-
},
|
|
83
|
-
[ModelType.TEXT_TOKENIZER_ENCODE]: async (): Promise<number[]> => {
|
|
84
|
-
warnUnsupported(ModelType.TEXT_TOKENIZER_ENCODE);
|
|
85
|
-
return [];
|
|
86
|
-
},
|
|
87
|
-
[ModelType.TEXT_TOKENIZER_DECODE]: async (): Promise<string> => {
|
|
88
|
-
warnUnsupported(ModelType.TEXT_TOKENIZER_DECODE);
|
|
89
|
-
return "";
|
|
90
|
-
},
|
|
91
|
-
[ModelType.OBJECT_SMALL]: async (
|
|
92
|
-
_runtime: IAgentRuntime,
|
|
93
|
-
_params: ObjectGenerationParams
|
|
94
|
-
): Promise<Record<string, string>> => unsupportedObject(ModelType.OBJECT_SMALL),
|
|
95
|
-
[ModelType.OBJECT_LARGE]: async (
|
|
96
|
-
_runtime: IAgentRuntime,
|
|
97
|
-
_params: ObjectGenerationParams
|
|
98
|
-
): Promise<Record<string, string>> => unsupportedObject(ModelType.OBJECT_LARGE),
|
|
99
|
-
[ModelType.IMAGE_DESCRIPTION]: async (
|
|
100
|
-
_runtime: IAgentRuntime,
|
|
101
|
-
_params: ImageDescriptionParams | string
|
|
102
|
-
): Promise<ImageDescriptionResult> => unsupportedImageDescription(ModelType.IMAGE_DESCRIPTION),
|
|
103
|
-
[ModelType.TRANSCRIPTION]: async (): Promise<string> =>
|
|
104
|
-
unsupportedText(ModelType.TRANSCRIPTION),
|
|
105
|
-
[ModelType.TEXT_TO_SPEECH]: async (): Promise<Uint8Array> => {
|
|
106
|
-
warnUnsupported(ModelType.TEXT_TO_SPEECH);
|
|
107
|
-
return new Uint8Array();
|
|
108
|
-
},
|
|
109
|
-
[ModelType.IMAGE]: async (): Promise<ImageGenerationResult[]> => {
|
|
110
|
-
warnUnsupported(ModelType.IMAGE);
|
|
111
|
-
return [];
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export default localAiPlugin;
|