@elizaos/plugin-local-ai 1.0.0-beta.24 → 1.0.0-beta.26
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/README.md +0 -39
- package/dist/index.js +13 -82
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -18,15 +18,6 @@ The plugin requires these environment variables (can be set in .env file or char
|
|
|
18
18
|
"settings": {
|
|
19
19
|
"USE_LOCAL_AI": true,
|
|
20
20
|
"USE_STUDIOLM_TEXT_MODELS": false,
|
|
21
|
-
"USE_OLLAMA_TEXT_MODELS": false,
|
|
22
|
-
|
|
23
|
-
"OLLAMA_API_ENDPOINT": "http://localhost:11434",
|
|
24
|
-
"OLLAMA_MODEL": "deepseek-r1-distill-qwen-7b",
|
|
25
|
-
"USE_OLLAMA_EMBEDDING": false,
|
|
26
|
-
"OLLAMA_EMBEDDING_MODEL": "",
|
|
27
|
-
"OLLAMA_SMALL_MODEL": "deepseek-r1:1.5b",
|
|
28
|
-
"OLLAMA_MEDIUM_MODEL": "deepseek-r1:7b",
|
|
29
|
-
"OLLAMA_LARGE_MODEL": "deepseek-r1:7b",
|
|
30
21
|
|
|
31
22
|
"STUDIOLM_SERVER_URL": "http://localhost:1234",
|
|
32
23
|
"STUDIOLM_SMALL_MODEL": "lmstudio-community/deepseek-r1-distill-qwen-1.5b",
|
|
@@ -41,16 +32,6 @@ Or in `.env` file:
|
|
|
41
32
|
# Local AI Configuration
|
|
42
33
|
USE_LOCAL_AI=true
|
|
43
34
|
USE_STUDIOLM_TEXT_MODELS=false
|
|
44
|
-
USE_OLLAMA_TEXT_MODELS=false
|
|
45
|
-
|
|
46
|
-
# Ollama Configuration
|
|
47
|
-
OLLAMA_API_ENDPOINT=http://localhost:11434
|
|
48
|
-
OLLAMA_MODEL=deepseek-r1-distill-qwen-7b
|
|
49
|
-
USE_OLLAMA_EMBEDDING=false
|
|
50
|
-
OLLAMA_EMBEDDING_MODEL=
|
|
51
|
-
OLLAMA_SMALL_MODEL=deepseek-r1:1.5b
|
|
52
|
-
OLLAMA_MEDIUM_MODEL=deepseek-r1:7b
|
|
53
|
-
OLLAMA_LARGE_MODEL=deepseek-r1:7b
|
|
54
35
|
|
|
55
36
|
# StudioLM Configuration
|
|
56
37
|
STUDIOLM_SERVER_URL=http://localhost:1234
|
|
@@ -64,18 +45,6 @@ STUDIOLM_EMBEDDING_MODEL=false
|
|
|
64
45
|
#### Text Model Source (Choose One)
|
|
65
46
|
|
|
66
47
|
- `USE_STUDIOLM_TEXT_MODELS`: Enable StudioLM text models
|
|
67
|
-
- `USE_OLLAMA_TEXT_MODELS`: Enable Ollama text models
|
|
68
|
-
Note: Only one text model source can be enabled at a time
|
|
69
|
-
|
|
70
|
-
#### Ollama Settings
|
|
71
|
-
|
|
72
|
-
- `OLLAMA_API_ENDPOINT`: Ollama API endpoint (default: http://localhost:11434)
|
|
73
|
-
- `OLLAMA_MODEL`: Default model for general use
|
|
74
|
-
- `USE_OLLAMA_EMBEDDING`: Enable Ollama for embeddings
|
|
75
|
-
- `OLLAMA_EMBEDDING_MODEL`: Model for embeddings when enabled
|
|
76
|
-
- `OLLAMA_SMALL_MODEL`: Model for lighter tasks
|
|
77
|
-
- `OLLAMA_MEDIUM_MODEL`: Model for standard tasks
|
|
78
|
-
- `OLLAMA_LARGE_MODEL`: Model for complex tasks
|
|
79
48
|
|
|
80
49
|
#### StudioLM Settings
|
|
81
50
|
|
|
@@ -141,12 +110,4 @@ const largeResponse = await runtime.useModel(ModelType.TEXT_LARGE, {
|
|
|
141
110
|
- Supports both small and medium-sized models
|
|
142
111
|
- Optional embedding model support
|
|
143
112
|
|
|
144
|
-
### 2. Ollama
|
|
145
|
-
|
|
146
|
-
- Local model server with optimized inference
|
|
147
|
-
- Supports various open models in GGUF format
|
|
148
|
-
- Configure with `USE_OLLAMA_TEXT_MODELS=true`
|
|
149
|
-
- Supports small, medium, and large models
|
|
150
|
-
- Optional embedding model support
|
|
151
|
-
|
|
152
113
|
Note: The plugin validates that only one text model source is enabled at a time to prevent conflicts.
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import path5 from "node:path";
|
|
|
5
5
|
import { Readable as Readable2 } from "node:stream";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { ModelType as ModelType2, logger as logger9 } from "@elizaos/core";
|
|
8
|
-
import
|
|
8
|
+
import pkg from "fastembed";
|
|
9
9
|
import {
|
|
10
10
|
LlamaChatSession,
|
|
11
11
|
getLlama as getLlama2
|
|
@@ -2341,6 +2341,7 @@ var VisionManager = class _VisionManager {
|
|
|
2341
2341
|
};
|
|
2342
2342
|
|
|
2343
2343
|
// src/index.ts
|
|
2344
|
+
var { EmbeddingModel, FlagEmbedding } = pkg;
|
|
2344
2345
|
var __filename = fileURLToPath(import.meta.url);
|
|
2345
2346
|
var __dirname = path5.dirname(__filename);
|
|
2346
2347
|
var wordsToPunish = [
|
|
@@ -2412,8 +2413,7 @@ var LocalAIManager = class _LocalAIManager {
|
|
|
2412
2413
|
transcribeManager;
|
|
2413
2414
|
ttsManager;
|
|
2414
2415
|
studioLMManager;
|
|
2415
|
-
// Initialization state
|
|
2416
|
-
ollamaInitialized = false;
|
|
2416
|
+
// Initialization state flag
|
|
2417
2417
|
studioLMInitialized = false;
|
|
2418
2418
|
smallModelInitialized = false;
|
|
2419
2419
|
mediumModelInitialized = false;
|
|
@@ -2428,7 +2428,6 @@ var LocalAIManager = class _LocalAIManager {
|
|
|
2428
2428
|
visionInitializingPromise = null;
|
|
2429
2429
|
transcriptionInitializingPromise = null;
|
|
2430
2430
|
ttsInitializingPromise = null;
|
|
2431
|
-
ollamaInitializingPromise = null;
|
|
2432
2431
|
studioLMInitializingPromise = null;
|
|
2433
2432
|
modelsDir;
|
|
2434
2433
|
/**
|
|
@@ -2489,14 +2488,12 @@ var LocalAIManager = class _LocalAIManager {
|
|
|
2489
2488
|
logger9.info("Validating environment configuration...");
|
|
2490
2489
|
const config = {
|
|
2491
2490
|
USE_LOCAL_AI: process.env.USE_LOCAL_AI,
|
|
2492
|
-
USE_STUDIOLM_TEXT_MODELS: process.env.USE_STUDIOLM_TEXT_MODELS
|
|
2493
|
-
USE_OLLAMA_TEXT_MODELS: process.env.USE_OLLAMA_TEXT_MODELS
|
|
2491
|
+
USE_STUDIOLM_TEXT_MODELS: process.env.USE_STUDIOLM_TEXT_MODELS
|
|
2494
2492
|
};
|
|
2495
2493
|
const validatedConfig = await validateConfig(config);
|
|
2496
2494
|
logger9.info("Environment configuration validated");
|
|
2497
2495
|
process.env.USE_LOCAL_AI = String(validatedConfig.USE_LOCAL_AI);
|
|
2498
2496
|
process.env.USE_STUDIOLM_TEXT_MODELS = String(validatedConfig.USE_STUDIOLM_TEXT_MODELS);
|
|
2499
|
-
process.env.USE_OLLAMA_TEXT_MODELS = String(validatedConfig.USE_OLLAMA_TEXT_MODELS);
|
|
2500
2497
|
logger9.success("Environment initialization complete");
|
|
2501
2498
|
} catch (error) {
|
|
2502
2499
|
logger9.error("Environment validation failed:", {
|
|
@@ -2506,32 +2503,6 @@ var LocalAIManager = class _LocalAIManager {
|
|
|
2506
2503
|
throw error;
|
|
2507
2504
|
}
|
|
2508
2505
|
}
|
|
2509
|
-
/**
|
|
2510
|
-
* Asynchronously initializes the Ollama model.
|
|
2511
|
-
*
|
|
2512
|
-
* @returns {Promise<void>} A Promise that resolves when the initialization is complete.
|
|
2513
|
-
* @throws {Error} If the Ollama manager is not created, or if initialization of Ollama models fails.
|
|
2514
|
-
*/
|
|
2515
|
-
async initializeOllama() {
|
|
2516
|
-
try {
|
|
2517
|
-
logger9.info("Initializing Ollama models...");
|
|
2518
|
-
if (!this.ollamaManager) {
|
|
2519
|
-
throw new Error("Ollama manager not created - cannot initialize");
|
|
2520
|
-
}
|
|
2521
|
-
await this.ollamaManager.initialize();
|
|
2522
|
-
if (!this.ollamaManager.isInitialized()) {
|
|
2523
|
-
throw new Error("Ollama initialization failed - models not properly loaded");
|
|
2524
|
-
}
|
|
2525
|
-
logger9.success("Ollama initialization complete");
|
|
2526
|
-
} catch (error) {
|
|
2527
|
-
logger9.error("Ollama initialization failed:", {
|
|
2528
|
-
error: error instanceof Error ? error.message : String(error),
|
|
2529
|
-
stack: error instanceof Error ? error.stack : void 0,
|
|
2530
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2531
|
-
});
|
|
2532
|
-
throw error;
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2535
2506
|
/**
|
|
2536
2507
|
* Initializes StudioLM model with error handling.
|
|
2537
2508
|
* @returns A Promise that resolves when the initialization is complete.
|
|
@@ -2649,21 +2620,19 @@ var LocalAIManager = class _LocalAIManager {
|
|
|
2649
2620
|
}
|
|
2650
2621
|
}
|
|
2651
2622
|
/**
|
|
2652
|
-
* Asynchronously generates text using
|
|
2623
|
+
* Asynchronously generates text using StudioLM models based on the specified parameters.
|
|
2653
2624
|
*
|
|
2654
2625
|
* @param {GenerateTextParams} params - The parameters for generating the text.
|
|
2655
2626
|
* @returns {Promise<string>} - A promise that resolves to the generated text.
|
|
2656
2627
|
*/
|
|
2657
|
-
async
|
|
2628
|
+
async generateTextLMStudio(params) {
|
|
2658
2629
|
try {
|
|
2659
2630
|
const modelConfig = this.getTextModelSource();
|
|
2660
|
-
logger9.info("
|
|
2631
|
+
logger9.info("generateTextLMStudio called with:", {
|
|
2661
2632
|
modelSource: modelConfig.source,
|
|
2662
2633
|
modelType: params.modelType,
|
|
2663
2634
|
studioLMInitialized: this.studioLMInitialized,
|
|
2664
|
-
|
|
2665
|
-
studioLMEnabled: process.env.USE_STUDIOLM_TEXT_MODELS === "true",
|
|
2666
|
-
ollamaEnabled: process.env.USE_OLLAMA_TEXT_MODELS === "true"
|
|
2635
|
+
studioLMEnabled: process.env.USE_STUDIOLM_TEXT_MODELS === "true"
|
|
2667
2636
|
});
|
|
2668
2637
|
if (modelConfig.source === "studiolm") {
|
|
2669
2638
|
if (process.env.USE_STUDIOLM_TEXT_MODELS !== "true") {
|
|
@@ -2682,25 +2651,9 @@ var LocalAIManager = class _LocalAIManager {
|
|
|
2682
2651
|
}
|
|
2683
2652
|
return await this.studioLMManager.generateText(params, this.studioLMInitialized);
|
|
2684
2653
|
}
|
|
2685
|
-
if (modelConfig.source === "ollama") {
|
|
2686
|
-
if (process.env.USE_OLLAMA_TEXT_MODELS !== "true") {
|
|
2687
|
-
logger9.warn("Ollama requested but disabled in environment, falling back to local models");
|
|
2688
|
-
return this.generateText(params);
|
|
2689
|
-
}
|
|
2690
|
-
if (!this.ollamaManager) {
|
|
2691
|
-
logger9.warn("Ollama manager not initialized, falling back to local models");
|
|
2692
|
-
return this.generateText(params);
|
|
2693
|
-
}
|
|
2694
|
-
if (!this.ollamaInitialized && !this.ollamaManager.isInitialized()) {
|
|
2695
|
-
logger9.info("Initializing Ollama in generateTextOllamaStudio");
|
|
2696
|
-
await this.ollamaManager.initialize();
|
|
2697
|
-
this.ollamaInitialized = true;
|
|
2698
|
-
}
|
|
2699
|
-
return await this.ollamaManager.generateText(params, this.ollamaInitialized);
|
|
2700
|
-
}
|
|
2701
2654
|
return this.generateText(params);
|
|
2702
2655
|
} catch (error) {
|
|
2703
|
-
logger9.error("Text generation with
|
|
2656
|
+
logger9.error("Text generation with StudioLM failed:", {
|
|
2704
2657
|
error: error instanceof Error ? error.message : String(error),
|
|
2705
2658
|
stack: error instanceof Error ? error.stack : void 0,
|
|
2706
2659
|
modelSource: this.getTextModelSource().source
|
|
@@ -2884,8 +2837,6 @@ var LocalAIManager = class _LocalAIManager {
|
|
|
2884
2837
|
};
|
|
2885
2838
|
if (process.env.USE_STUDIOLM_TEXT_MODELS === "true" && this.studioLMManager) {
|
|
2886
2839
|
config.source = "studiolm";
|
|
2887
|
-
} else if (process.env.USE_OLLAMA_TEXT_MODELS === "true" && this.ollamaManager) {
|
|
2888
|
-
config.source = "ollama";
|
|
2889
2840
|
}
|
|
2890
2841
|
logger9.info("Selected text model source:", config);
|
|
2891
2842
|
return config;
|
|
@@ -3049,26 +3000,6 @@ var LocalAIManager = class _LocalAIManager {
|
|
|
3049
3000
|
}
|
|
3050
3001
|
await this.ttsInitializingPromise;
|
|
3051
3002
|
}
|
|
3052
|
-
/**
|
|
3053
|
-
* Lazy initialize the Ollama integration
|
|
3054
|
-
*/
|
|
3055
|
-
async lazyInitOllama() {
|
|
3056
|
-
if (this.ollamaInitialized) return;
|
|
3057
|
-
if (!this.ollamaInitializingPromise) {
|
|
3058
|
-
this.ollamaInitializingPromise = (async () => {
|
|
3059
|
-
try {
|
|
3060
|
-
await this.initializeOllama();
|
|
3061
|
-
this.ollamaInitialized = true;
|
|
3062
|
-
logger9.info("Ollama initialized successfully");
|
|
3063
|
-
} catch (error) {
|
|
3064
|
-
logger9.error("Failed to initialize Ollama:", error);
|
|
3065
|
-
this.ollamaInitializingPromise = null;
|
|
3066
|
-
throw error;
|
|
3067
|
-
}
|
|
3068
|
-
})();
|
|
3069
|
-
}
|
|
3070
|
-
await this.ollamaInitializingPromise;
|
|
3071
|
-
}
|
|
3072
3003
|
/**
|
|
3073
3004
|
* Lazy initialize the StudioLM integration
|
|
3074
3005
|
*/
|
|
@@ -3111,7 +3042,7 @@ var localAiPlugin = {
|
|
|
3111
3042
|
try {
|
|
3112
3043
|
const modelConfig = localAIManager.getTextModelSource();
|
|
3113
3044
|
if (modelConfig.source !== "local") {
|
|
3114
|
-
return await localAIManager.
|
|
3045
|
+
return await localAIManager.generateTextLMStudio({
|
|
3115
3046
|
prompt,
|
|
3116
3047
|
stopSequences,
|
|
3117
3048
|
runtime,
|
|
@@ -3133,7 +3064,7 @@ var localAiPlugin = {
|
|
|
3133
3064
|
try {
|
|
3134
3065
|
const modelConfig = localAIManager.getTextModelSource();
|
|
3135
3066
|
if (modelConfig.source !== "local") {
|
|
3136
|
-
return await localAIManager.
|
|
3067
|
+
return await localAIManager.generateTextLMStudio({
|
|
3137
3068
|
prompt,
|
|
3138
3069
|
stopSequences,
|
|
3139
3070
|
runtime,
|
|
@@ -3183,7 +3114,7 @@ var localAiPlugin = {
|
|
|
3183
3114
|
const modelConfig = localAIManager.getTextModelSource();
|
|
3184
3115
|
let textResponse;
|
|
3185
3116
|
if (modelConfig.source !== "local") {
|
|
3186
|
-
textResponse = await localAIManager.
|
|
3117
|
+
textResponse = await localAIManager.generateTextLMStudio({
|
|
3187
3118
|
prompt: jsonPrompt,
|
|
3188
3119
|
stopSequences: params.stopSequences,
|
|
3189
3120
|
runtime,
|
|
@@ -3262,7 +3193,7 @@ var localAiPlugin = {
|
|
|
3262
3193
|
const modelConfig = localAIManager.getTextModelSource();
|
|
3263
3194
|
let textResponse;
|
|
3264
3195
|
if (modelConfig.source !== "local") {
|
|
3265
|
-
textResponse = await localAIManager.
|
|
3196
|
+
textResponse = await localAIManager.generateTextLMStudio({
|
|
3266
3197
|
prompt: jsonPrompt,
|
|
3267
3198
|
stopSequences: params.stopSequences,
|
|
3268
3199
|
runtime,
|