@elizaos/plugin-ollama 2.0.0-beta.1 → 2.0.3-beta.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.
Files changed (44) hide show
  1. package/README.md +12 -27
  2. package/package.json +14 -9
  3. package/dist/browser/index.browser.js +0 -1063
  4. package/dist/browser/index.browser.js.map +0 -17
  5. package/dist/browser/index.d.ts +0 -2
  6. package/dist/cjs/index.d.ts +0 -2
  7. package/dist/cjs/index.node.cjs +0 -1091
  8. package/dist/cjs/index.node.cjs.map +0 -17
  9. package/dist/node/auto-enable.d.ts +0 -4
  10. package/dist/node/auto-enable.d.ts.map +0 -1
  11. package/dist/node/build.d.ts +0 -2
  12. package/dist/node/build.d.ts.map +0 -1
  13. package/dist/node/generated/specs/specs.d.ts +0 -38
  14. package/dist/node/generated/specs/specs.d.ts.map +0 -1
  15. package/dist/node/index.browser.d.ts +0 -7
  16. package/dist/node/index.browser.d.ts.map +0 -1
  17. package/dist/node/index.d.ts +0 -2
  18. package/dist/node/index.d.ts.map +0 -1
  19. package/dist/node/index.node.d.ts +0 -7
  20. package/dist/node/index.node.d.ts.map +0 -1
  21. package/dist/node/index.node.js +0 -1063
  22. package/dist/node/index.node.js.map +0 -17
  23. package/dist/node/models/availability.d.ts +0 -2
  24. package/dist/node/models/availability.d.ts.map +0 -1
  25. package/dist/node/models/embedding.d.ts +0 -10
  26. package/dist/node/models/embedding.d.ts.map +0 -1
  27. package/dist/node/models/index.d.ts +0 -4
  28. package/dist/node/models/index.d.ts.map +0 -1
  29. package/dist/node/models/text.d.ts +0 -83
  30. package/dist/node/models/text.d.ts.map +0 -1
  31. package/dist/node/plugin.d.ts +0 -37
  32. package/dist/node/plugin.d.ts.map +0 -1
  33. package/dist/node/types/index.d.ts +0 -47
  34. package/dist/node/types/index.d.ts.map +0 -1
  35. package/dist/node/utils/ai-sdk-wire.d.ts +0 -42
  36. package/dist/node/utils/ai-sdk-wire.d.ts.map +0 -1
  37. package/dist/node/utils/config.d.ts +0 -40
  38. package/dist/node/utils/config.d.ts.map +0 -1
  39. package/dist/node/utils/index.d.ts +0 -4
  40. package/dist/node/utils/index.d.ts.map +0 -1
  41. package/dist/node/utils/modelUsage.d.ts +0 -13
  42. package/dist/node/utils/modelUsage.d.ts.map +0 -1
  43. package/dist/node/vitest.config.d.ts +0 -3
  44. package/dist/node/vitest.config.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,17 +1,11 @@
1
1
  # Ollama Plugin
2
2
 
3
- This plugin connects [Ollama](https://ollama.com/) to ElizaOS so agents can use **local** LLMs for text, embeddings, and JSON object generation—without sending prompts to a third-party API.
4
-
5
- ## Why this plugin exists
6
-
7
- - **Privacy and compliance:** All inference can stay on your LAN or laptop.
8
- - **Cost:** No per-token cloud billing for experimentation.
9
- - **Offline / air-gapped:** Works wherever Ollama runs, including containers and remote servers.
3
+ This plugin connects [Ollama](https://ollama.com/) to elizaOS so agents can use **local** LLMs for text, embeddings, and structured output—without sending prompts to a third-party API.
10
4
 
11
5
  ## Requirements
12
6
 
13
7
  - [Ollama](https://ollama.com/) installed and reachable (same machine or network).
14
- - ElizaOS runtime with this package enabled.
8
+ - elizaOS runtime with this package enabled.
15
9
  - At least one Eliza-1 model created, e.g. `ollama create eliza-1-2b -f packages/training/cloud/ollama/Modelfile.eliza-1-2b-q4_k_m`.
16
10
 
17
11
  ## Installation
@@ -26,7 +20,7 @@ Ensure Ollama is running:
26
20
  ollama serve
27
21
  ```
28
22
 
29
- Register the plugin on your character / app config (exact shape depends on your ElizaOS version):
23
+ Register the plugin on your character / app config (exact shape depends on your elizaOS version):
30
24
 
31
25
  ```json
32
26
  "plugins": ["@elizaos/plugin-ollama"]
@@ -34,7 +28,7 @@ Register the plugin on your character / app config (exact shape depends on your
34
28
 
35
29
  ## Architecture: Vercel AI SDK + `ollama-ai-provider-v2`
36
30
 
37
- Handlers use **`generateText`** (completion, structured generation, and non-streaming fallbacks for schema-only stream contexts or toolChoice-only requests), **`streamText`** (plain SSE chat **or** `stream: true` **with native tools**), **`generateObject`**, and **`embed`** from the **`ai`** package, backed by **`ollama-ai-provider-v2`**.
31
+ Handlers use **`generateText`** (completion, structured generation, and non-streaming fallbacks for schema-only stream contexts or toolChoice-only requests), **`streamText`** (plain SSE chat **or** `stream: true` **with native tools**), and **`embed`** from the **`ai`** package, backed by **`ollama-ai-provider-v2`**.
38
32
 
39
33
  ## Streaming chat (`TextStreamResult`)
40
34
 
@@ -45,7 +39,7 @@ This plugin returns **`TextStreamResult`** from **`streamText`** when **`stream:
45
39
  - **Plain chat:** no **`responseSchema`**, **tools**, or **`toolChoice`** — every text delta is yielded to **`textStream`** (normal SSE).
46
40
  - **Native tools:** **tools** are present — Ollama streams the chat request with tools on the wire. For **`RESPONSE_HANDLER`** / **`ACTION_PLANNER`**, **`useModel`**’s streaming path concatenates only **`textStream`** chunks into the string passed to **`parseMessageHandlerOutput`**, so this adapter **drains** model text deltas internally and **yields a single trailing chunk** of the first tool’s **`arguments`** JSON (the v5 plan). **Why:** prepending arbitrary streamed text would break **`JSON.parse`** on that accumulated string. Other **`TEXT_*`** types forward all text chunks and attach **`toolCalls`** on the result (parity with OpenAI/OpenRouter).
47
41
 
48
- **Still `generateText`:** **`stream: true`** with **`responseSchema`** only (no tools), e.g. nested **`FACT_EXTRACTOR`** during SSE — **`stream` may still be true** on params; we **do not throw** and we **log at debug** because structured **`format: json`** is not wired through **`streamText`** here.
42
+ **Still `generateText`:** **`stream: true`** with **`responseSchema`** only (no tools), e.g. nested **`FACT_EXTRACTOR`** during SSE — **`stream` may still be true** on params; we **do not throw** and we **log at debug** because this adapter intentionally keeps structured **`format: json`** on the completion path.
49
43
 
50
44
  **Still `generateText`:** **`stream: true`** with **`toolChoice`** but **no** resolved **`ToolSet`** on the wire — **log at debug**, then **`generateText`**. **Why:** the AI SDK’s **`streamText`** path used here expects **`tools`** in the same request; `toolChoice` alone is invalid for streaming and is not produced by core v5 (Stage 1 always passes tools with `toolChoice`).
51
45
 
@@ -55,13 +49,13 @@ This plugin returns **`TextStreamResult`** from **`streamText`** when **`stream:
55
49
  |----------|-----------------|----------------------------------|------|-----|
56
50
  | `true` | yes | (any; schema dropped if both) | **`streamText`** + tools | Same surface as other provider plugins; Ollama v2 supports tools on streaming `/api/chat`. |
57
51
  | `true` | no | no schema, no `toolChoice` | **`streamText`** plain | **`TextStreamResult`** so `useModel` can forward SSE chunks. |
58
- | `true` | no | schema only | **`generateText`** | Structured **`format`** is not implemented on **`streamText`** in this adapter; nested schema calls must not throw. |
52
+ | `true` | no | schema only | **`generateText`** | Structured **`format`** stays on the completion path in this adapter; nested schema calls must not throw. |
59
53
  | `true` | no | `toolChoice` only | **`generateText`** | **`streamText`+tools** requires a tool set; log explains misconfiguration. |
60
54
  | `false` / absent | (any) | (any) | **`generateText`** (or structured serialize) | Normal completion path; Stage 1 without inherited streaming uses this. |
61
55
 
62
56
  ### Why `ollama-ai-provider-v2` (not the old `ollama-ai-provider`)
63
57
 
64
- ElizaOS tracks **AI SDK 5/6**. Older `ollama-ai-provider` exposed **model specification v1**; current `ai` only accepts **v2+** models and throws:
58
+ elizaOS tracks **AI SDK 5/6**. Older `ollama-ai-provider` exposed **model specification v1**; current `ai` only accepts **v2+** models and throws:
65
59
 
66
60
  `Unsupported model version v1 for provider "ollama.chat"`.
67
61
 
@@ -77,7 +71,7 @@ Environment variables (or character `settings` with the same keys—**why:** let
77
71
  |----------|---------|---------|
78
72
  | `OLLAMA_API_ENDPOINT` | `http://localhost:11434` (normalized to `…/api`) | Ollama HTTP API base. |
79
73
  | `OLLAMA_SMALL_MODEL` / `SMALL_MODEL` | `eliza-1-2b` | Small / fast text model. |
80
- | `OLLAMA_LARGE_MODEL` / `LARGE_MODEL` | `eliza-1-9b` | Larger text model. |
74
+ | `OLLAMA_LARGE_MODEL` / `LARGE_MODEL` | `eliza-1-4b` | Larger text model. |
81
75
  | `OLLAMA_EMBEDDING_MODEL` | `eliza-1-2b` | Embedding model id. |
82
76
  | `OLLAMA_DISABLE_STRUCTURED_OUTPUT` | _unset_ | If `1` / `true` / `yes` / `on`, **disables** JSON-schema structured text (see below). |
83
77
 
@@ -88,7 +82,7 @@ Optional model overrides: `OLLAMA_NANO_MODEL`, `OLLAMA_MEDIUM_MODEL`, `OLLAMA_ME
88
82
  ```
89
83
  OLLAMA_API_ENDPOINT=http://localhost:11434/api
90
84
  OLLAMA_SMALL_MODEL=eliza-1-2b
91
- OLLAMA_LARGE_MODEL=eliza-1-9b
85
+ OLLAMA_LARGE_MODEL=eliza-1-4b
92
86
  OLLAMA_EMBEDDING_MODEL=eliza-1-2b
93
87
  ```
94
88
 
@@ -99,7 +93,7 @@ OLLAMA_EMBEDDING_MODEL=eliza-1-2b
99
93
  "settings": {
100
94
  "OLLAMA_API_ENDPOINT": "http://localhost:11434/api",
101
95
  "OLLAMA_SMALL_MODEL": "eliza-1-2b",
102
- "OLLAMA_LARGE_MODEL": "eliza-1-9b",
96
+ "OLLAMA_LARGE_MODEL": "eliza-1-4b",
103
97
  "OLLAMA_EMBEDDING_MODEL": "eliza-1-2b"
104
98
  }
105
99
  }
@@ -133,7 +127,6 @@ Set to `1`, `true`, `yes`, or `on` if:
133
127
  |------------|------|
134
128
  | `TEXT_*` | Chat / completion-style text. |
135
129
  | `TEXT_EMBEDDING` | Vector embeddings. |
136
- | `OBJECT_*` | `generateObject` with `output: "no-schema"` (best-effort JSON object). |
137
130
  | `RESPONSE_HANDLER` / `ACTION_PLANNER` | Same text path; v5 Stage 1 uses **messages + tools + `toolChoice`**; other pipelines may use **`responseSchema`** for JSON. |
138
131
 
139
132
  ### Text example
@@ -156,7 +149,7 @@ const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {
156
149
 
157
150
  ## Chat messages, native tools, and `toolChoice` (v5)
158
151
 
159
- ElizaOS v5 can call text models with **`messages`** (chat turns), **`tools`** (function / tool definitions), and **`toolChoice`** (for example `"required"` on the message-handler stage so the model must emit a planner tool call).
152
+ elizaOS v5 can call text models with **`messages`** (chat turns), **`tools`** (function / tool definitions), and **`toolChoice`** (for example `"required"` on the message-handler stage so the model must emit a planner tool call).
160
153
 
161
154
  This plugin forwards those fields to the Vercel AI SDK **`generateText`** or **`streamText`** (when **`stream: true`** and tools are present) backed by **`ollama-ai-provider-v2`**, and when the call is “native shaped” (messages, tools, tool choice, or structured output), it may return a **`GenerateTextResult`-like object at runtime** or a **`TextStreamResult`** with **`toolCalls`** — TypeScript still types `useModel` text handlers as `string` for historical reasons.
162
155
 
@@ -186,16 +179,8 @@ This plugin forwards those fields to the Vercel AI SDK **`generateText`** or **`
186
179
  | **`streamText.textStream` failed** / **`AI_NoOutputGeneratedError`** / process exit after Ollama **500** | Ollama returned an error body (e.g. **insufficient system memory** for the model) during a **streaming** `/api/chat` call; AI SDK retried then failed. | Check logs for **`ollamaResponseBody`** (plugin now extracts it). Free RAM on the Ollama host, use a smaller model, or lower concurrency. Streaming errors occur while **`useModel`** consumes **`textStream`**, not only inside **`generateText`**. |
187
180
  | Connection errors | Ollama not running or wrong URL | `curl` the `/api/tags` endpoint; fix `OLLAMA_API_ENDPOINT`. |
188
181
 
189
- More context: [Ollama plugin docs](https://docs.eliza.ai/) (registry page: `plugin-registry/llm/ollama`).
190
-
191
- ## API reference
192
-
193
- Ollama’s HTTP API: [Ollama API docs](https://github.com/ollama/ollama/blob/main/docs/api.md).
182
+ More context: [elizaOS documentation](https://docs.elizaos.ai/).
194
183
 
195
184
  ## Changelog
196
185
 
197
186
  See **[CHANGELOG.md](./CHANGELOG.md)**.
198
-
199
- ## License
200
-
201
- See [LICENSE](./LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-ollama",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.3-beta.2",
4
4
  "type": "module",
5
5
  "main": "dist/node/index.node.js",
6
6
  "module": "dist/node/index.node.js",
@@ -28,6 +28,12 @@
28
28
  "default": "./dist/node/index.node.js"
29
29
  },
30
30
  "default": "./dist/node/index.node.js"
31
+ },
32
+ "./*.css": "./dist/*.css",
33
+ "./*": {
34
+ "types": "./dist/*.d.ts",
35
+ "import": "./dist/*.js",
36
+ "default": "./dist/*.js"
31
37
  }
32
38
  },
33
39
  "files": [
@@ -46,21 +52,20 @@
46
52
  },
47
53
  "sideEffects": false,
48
54
  "dependencies": {
49
- "@ai-sdk/ui-utils": "^1.2.8",
50
55
  "ai": "^6.0.174",
51
- "js-tiktoken": "^1.0.18",
52
- "ollama-ai-provider-v2": "^3.5.0"
56
+ "ollama-ai-provider-v2": "^3.5.0",
57
+ "zod": "^4.4.3"
53
58
  },
54
59
  "devDependencies": {
55
60
  "@biomejs/biome": "^2.4.14",
56
- "@elizaos/core": "2.0.0-beta.1",
61
+ "@elizaos/core": "2.0.3-beta.2",
57
62
  "@types/node": "^25.0.3",
58
63
  "bun-types": "^1.3.12",
59
64
  "typescript": "^6.0.3",
60
65
  "vitest": "^4.0.0"
61
66
  },
62
67
  "peerDependencies": {
63
- "@elizaos/core": "2.0.0-beta.1"
68
+ "@elizaos/core": "2.0.3-beta.2"
64
69
  },
65
70
  "scripts": {
66
71
  "dev": "bun run build.ts --watch",
@@ -105,7 +110,7 @@
105
110
  "type": "string",
106
111
  "description": "Name or tag of the large-sized Ollama model to use for text and object generation.",
107
112
  "required": false,
108
- "default": "eliza-1-9b",
113
+ "default": "eliza-1-4b",
109
114
  "sensitive": false
110
115
  },
111
116
  "OLLAMA_EMBEDDING_MODEL": {
@@ -132,12 +137,12 @@
132
137
  "type": "string",
133
138
  "description": "Fallback environment variable for specifying a large model if OLLAMA_LARGE_MODEL is not set.",
134
139
  "required": false,
135
- "default": "eliza-1-9b",
140
+ "default": "eliza-1-4b",
136
141
  "sensitive": false
137
142
  }
138
143
  }
139
144
  },
140
- "gitHead": "646c632924826e2b75c2304a75ee56959fe4a460",
145
+ "gitHead": "82fe0f44215954c2417328203f5bd6510985c1fc",
141
146
  "eliza": {
142
147
  "platforms": [
143
148
  "browser",