@elizaos/plugin-local-ai 1.0.0-beta.8 → 1.0.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/README.md CHANGED
@@ -7,82 +7,39 @@ This plugin provides local AI model capabilities through the ElizaOS platform, s
7
7
  Add the plugin to your character configuration:
8
8
 
9
9
  ```json
10
- "plugins": ["@elizaos/plugin-local-ai"]
10
+ "plugins": ["@elizaos-plugins/plugin-local-ai"]
11
11
  ```
12
12
 
13
13
  ## Configuration
14
14
 
15
- The plugin requires these environment variables (can be set in .env file or character settings):
16
-
17
- ```json
18
- "settings": {
19
- "USE_LOCAL_AI": true,
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
-
31
- "STUDIOLM_SERVER_URL": "http://localhost:1234",
32
- "STUDIOLM_SMALL_MODEL": "lmstudio-community/deepseek-r1-distill-qwen-1.5b",
33
- "STUDIOLM_MEDIUM_MODEL": "deepseek-r1-distill-qwen-7b",
34
- "STUDIOLM_EMBEDDING_MODEL": false
35
- }
36
- ```
15
+ The plugin is configured using environment variables (typically set in a `.env` file or via your deployment settings):
37
16
 
38
17
  Or in `.env` file:
39
18
 
40
19
  ```env
41
- # Local AI Configuration
42
- USE_LOCAL_AI=true
43
- 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
-
55
- # StudioLM Configuration
56
- STUDIOLM_SERVER_URL=http://localhost:1234
57
- STUDIOLM_SMALL_MODEL=lmstudio-community/deepseek-r1-distill-qwen-1.5b
58
- STUDIOLM_MEDIUM_MODEL=deepseek-r1-distill-qwen-7b
59
- STUDIOLM_EMBEDDING_MODEL=false
60
- ```
61
-
62
- ### Configuration Options
20
+ # Optional: Specify a custom directory for models (GGUF files)
21
+ # MODELS_DIR=/path/to/your/models
63
22
 
64
- #### Text Model Source (Choose One)
23
+ # Optional: Specify a custom directory for caching other components (tokenizers, etc.)
24
+ # CACHE_DIR=/path/to/your/cache
65
25
 
66
- - `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
26
+ # Optional: Specify filenames for the text generation and embedding models within the models directory
27
+ # LOCAL_SMALL_MODEL=my-custom-small-model.gguf
28
+ # LOCAL_LARGE_MODEL=my-custom-large-model.gguf
29
+ # LOCAL_EMBEDDING_MODEL=my-custom-embedding-model.gguf
69
30
 
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
31
+ # Optional: Fallback dimension size for embeddings if generation fails. Defaults to the model's default (e.g., 384).
32
+ # LOCAL_EMBEDDING_DIMENSIONS=384
33
+ ```
79
34
 
80
- #### StudioLM Settings
35
+ ### Configuration Options
81
36
 
82
- - `STUDIOLM_SERVER_URL`: StudioLM API endpoint (default: http://localhost:1234)
83
- - `STUDIOLM_SMALL_MODEL`: Model for lighter tasks
84
- - `STUDIOLM_MEDIUM_MODEL`: Model for standard tasks
85
- - `STUDIOLM_EMBEDDING_MODEL`: Model for embeddings (or false to disable)
37
+ - `MODELS_DIR` (Optional): Specifies a custom directory for storing model files (GGUF format). If not set, defaults to `~/.eliza/models`.
38
+ - `CACHE_DIR` (Optional): Specifies a custom directory for caching other components like tokenizers. If not set, defaults to `~/.eliza/cache`.
39
+ - `LOCAL_SMALL_MODEL` (Optional): Specifies the filename for the small text generation model (e.g., `DeepHermes-3-Llama-3-3B-Preview-q4.gguf`) located in the models directory.
40
+ - `LOCAL_LARGE_MODEL` (Optional): Specifies the filename for the large text generation model (e.g., `DeepHermes-3-Llama-3-8B-q4.gguf`) located in the models directory.
41
+ - `LOCAL_EMBEDDING_MODEL` (Optional): Specifies the filename for the text embedding model (e.g., `bge-small-en-v1.5.Q4_K_M.gguf`) located in the models directory.
42
+ - `LOCAL_EMBEDDING_DIMENSIONS` (Optional): Defines the expected dimension size for text embeddings. This is primarily used as a fallback dimension if the embedding model fails to generate an embedding. If not set, it defaults to the embedding model's native dimension size (e.g., 384 for `bge-small-en-v1.5.Q4_K_M.gguf`).
86
43
 
87
44
  ## Features
88
45
 
@@ -90,10 +47,35 @@ The plugin provides these model classes:
90
47
 
91
48
  - `TEXT_SMALL`: Fast, efficient text generation using smaller models
92
49
  - `TEXT_LARGE`: More capable text generation using larger models
50
+ - `TEXT_EMBEDDING`: Generates text embeddings locally.
93
51
  - `IMAGE_DESCRIPTION`: Local image analysis using Florence-2 vision model
94
52
  - `TEXT_TO_SPEECH`: Local text-to-speech synthesis
95
53
  - `TRANSCRIPTION`: Local audio transcription using Whisper
96
54
 
55
+ ### Text Generation
56
+
57
+ ```typescript
58
+ // Using small model
59
+ const smallResponse = await runtime.useModel(ModelType.TEXT_SMALL, {
60
+ prompt: 'Generate a short response',
61
+ stopSequences: [],
62
+ });
63
+
64
+ // Using large model
65
+ const largeResponse = await runtime.useModel(ModelType.TEXT_LARGE, {
66
+ prompt: 'Generate a detailed response',
67
+ stopSequences: [],
68
+ });
69
+ ```
70
+
71
+ ### Text Embedding
72
+
73
+ ```typescript
74
+ const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {
75
+ text: 'Text to get embedding for',
76
+ });
77
+ ```
78
+
97
79
  ### Image Analysis
98
80
 
99
81
  ```typescript
@@ -114,39 +96,3 @@ const audioStream = await runtime.useModel(ModelType.TEXT_TO_SPEECH, 'Text to co
114
96
  ```typescript
115
97
  const transcription = await runtime.useModel(ModelType.TRANSCRIPTION, audioBuffer);
116
98
  ```
117
-
118
- ### Text Generation
119
-
120
- ```typescript
121
- // Using small model
122
- const smallResponse = await runtime.useModel(ModelType.TEXT_SMALL, {
123
- context: 'Generate a short response',
124
- stopSequences: [],
125
- });
126
-
127
- // Using large model
128
- const largeResponse = await runtime.useModel(ModelType.TEXT_LARGE, {
129
- context: 'Generate a detailed response',
130
- stopSequences: [],
131
- });
132
- ```
133
-
134
- ## Model Sources
135
-
136
- ### 1. StudioLM (LM Studio)
137
-
138
- - Local inference server for running various open models
139
- - Supports chat completion API similar to OpenAI
140
- - Configure with `USE_STUDIOLM_TEXT_MODELS=true`
141
- - Supports both small and medium-sized models
142
- - Optional embedding model support
143
-
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
- Note: The plugin validates that only one text model source is enabled at a time to prevent conflicts.
@@ -0,0 +1,9 @@
1
+ import { Plugin } from '@elizaos/core';
2
+
3
+ /**
4
+ * Plugin that provides functionality for local AI using LLaMA models.
5
+ * @type {Plugin}
6
+ */
7
+ declare const localAiPlugin: Plugin;
8
+
9
+ export { localAiPlugin as default, localAiPlugin };