@elizaos/plugin-ollama 1.2.4 → 2.0.0-alpha.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.
Files changed (39) hide show
  1. package/dist/browser/index.browser.js +424 -0
  2. package/dist/browser/index.browser.js.map +15 -0
  3. package/dist/browser/index.d.ts +2 -0
  4. package/dist/cjs/index.d.ts +2 -0
  5. package/dist/cjs/index.node.cjs +456 -0
  6. package/dist/cjs/index.node.cjs.map +15 -0
  7. package/dist/node/build.d.ts +2 -0
  8. package/dist/node/build.d.ts.map +1 -0
  9. package/dist/node/generated/specs/specs.d.ts +55 -0
  10. package/dist/node/generated/specs/specs.d.ts.map +1 -0
  11. package/dist/node/index.browser.d.ts +3 -0
  12. package/dist/node/index.browser.d.ts.map +1 -0
  13. package/dist/node/index.d.ts +2 -0
  14. package/dist/node/index.d.ts.map +1 -0
  15. package/dist/node/index.node.js +424 -0
  16. package/dist/node/index.node.js.map +15 -0
  17. package/dist/node/models/availability.d.ts +2 -0
  18. package/dist/node/models/availability.d.ts.map +1 -0
  19. package/dist/node/models/embedding.d.ts +3 -0
  20. package/dist/node/models/embedding.d.ts.map +1 -0
  21. package/dist/node/models/index.d.ts +5 -0
  22. package/dist/node/models/index.d.ts.map +1 -0
  23. package/dist/node/models/object.d.ts +4 -0
  24. package/dist/node/models/object.d.ts.map +1 -0
  25. package/dist/node/models/text.d.ts +4 -0
  26. package/dist/node/models/text.d.ts.map +1 -0
  27. package/dist/node/plugin.d.ts +3 -0
  28. package/dist/node/plugin.d.ts.map +1 -0
  29. package/dist/node/types/index.d.ts +47 -0
  30. package/dist/node/types/index.d.ts.map +1 -0
  31. package/dist/node/utils/config.d.ts +15 -0
  32. package/dist/node/utils/config.d.ts.map +1 -0
  33. package/dist/node/utils/index.d.ts +2 -0
  34. package/dist/node/utils/index.d.ts.map +1 -0
  35. package/package.json +41 -24
  36. package/LICENSE +0 -21
  37. package/README.md +0 -160
  38. package/dist/index.js +0 -356
  39. package/dist/index.js.map +0 -1
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-ollama",
3
- "version": "1.2.4",
3
+ "version": "2.0.0-alpha.1",
4
4
  "type": "module",
5
- "main": "dist/index.js",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
5
+ "main": "dist/node/index.node.js",
6
+ "module": "dist/node/index.node.js",
7
+ "types": "dist/node/index.d.ts",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/elizaos-plugins/plugin-ollama.git"
@@ -12,32 +12,54 @@
12
12
  "exports": {
13
13
  "./package.json": "./package.json",
14
14
  ".": {
15
- "import": {
16
- "types": "./dist/index.d.ts",
17
- "default": "./dist/index.js"
18
- }
15
+ "types": "./dist/node/index.d.ts",
16
+ "browser": {
17
+ "types": "./dist/browser/index.d.ts",
18
+ "import": "./dist/browser/index.browser.js",
19
+ "default": "./dist/browser/index.browser.js"
20
+ },
21
+ "node": {
22
+ "types": "./dist/node/index.d.ts",
23
+ "import": "./dist/node/index.node.js",
24
+ "default": "./dist/node/index.node.js"
25
+ },
26
+ "bun": {
27
+ "types": "./dist/node/index.d.ts",
28
+ "default": "./dist/node/index.node.js"
29
+ },
30
+ "require": "./dist/cjs/index.node.cjs",
31
+ "default": "./dist/node/index.node.js"
19
32
  }
20
33
  },
21
34
  "files": [
22
35
  "dist"
23
36
  ],
37
+ "sideEffects": false,
24
38
  "dependencies": {
25
39
  "@ai-sdk/ui-utils": "^1.2.8",
26
- "@elizaos/core": "^1.0.0",
40
+ "@elizaos/core": "workspace:*",
27
41
  "ai": "^4.3.9",
28
42
  "js-tiktoken": "^1.0.18",
29
- "ollama-ai-provider": "^1.2.0",
30
- "tsup": "8.4.0"
43
+ "ollama-ai-provider": "^1.2.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^25.0.3",
47
+ "typescript": "^5.9.3",
48
+ "@biomejs/biome": "^2.3.11"
31
49
  },
32
50
  "scripts": {
33
- "build": "tsup",
34
- "dev": "tsup --watch",
35
- "lint": "prettier --write ./src",
51
+ "dev": "bun run build.ts --watch",
52
+ "lint": "bunx @biomejs/biome check --write --unsafe .",
36
53
  "clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo",
37
- "format": "prettier --write ./src",
38
- "format:check": "prettier --check ./src",
39
- "test": "bun test",
40
- "postinstall": "bun scripts/install-ollama.js"
54
+ "format": "bunx @biomejs/biome format --write .",
55
+ "format:check": "bunx @biomejs/biome format .",
56
+ "typecheck": "tsc --noEmit -p tsconfig.json",
57
+ "test": "vitest run",
58
+ "test:unit": "vitest run __tests__/",
59
+ "postinstall": "bun scripts/install-ollama.js",
60
+ "lint:check": "bunx @biomejs/biome check .",
61
+ "build": "bun run build.ts",
62
+ "build:ts": "bun run build.ts"
41
63
  },
42
64
  "publishConfig": {
43
65
  "access": "public"
@@ -95,10 +117,5 @@
95
117
  }
96
118
  }
97
119
  },
98
- "gitHead": "646c632924826e2b75c2304a75ee56959fe4a460",
99
- "devDependencies": {
100
- "@types/node": "^24.0.4",
101
- "prettier": "3.5.3",
102
- "typescript": "^5.8.2"
103
- }
120
+ "gitHead": "646c632924826e2b75c2304a75ee56959fe4a460"
104
121
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Shaw Walters and elizaOS Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,160 +0,0 @@
1
- # Ollama Plugin
2
-
3
- This plugin provides integration with [Ollama](https://ollama.com/)'s local models through the ElizaOS platform. It allows you to leverage locally running LLMs for text generation, embeddings, and object generation.
4
-
5
- ## Overview
6
-
7
- Ollama enables running large language models locally on your machine. This plugin connects ElizaOS with your local Ollama installation, giving your characters access to powerful language models running on your own hardware.
8
-
9
- ## Requirements
10
-
11
- - [Ollama](https://ollama.com/) installed and running on your system
12
- - ElizaOS platform
13
- - At least one Ollama model pulled and available (e.g., `llama3`, `gemma3:latest`)
14
-
15
- ## Installation
16
-
17
- 1. Install this plugin in your ElizaOS project:
18
- ```bash
19
- bun add @elizaos-plugins/plugin-ollama
20
- ```
21
-
22
- 2. Make sure Ollama is running:
23
- ```bash
24
- ollama serve
25
- ```
26
-
27
- ## Usage
28
-
29
- Add the plugin to your character configuration:
30
-
31
- ```json
32
- "plugins": ["@elizaos-plugins/plugin-ollama"]
33
- ```
34
-
35
- ## Configuration
36
-
37
- The plugin requires these environment variables (can be set in .env file or character settings):
38
-
39
- ```json
40
- "settings": {
41
- "OLLAMA_API_ENDPOINT": "http://localhost:11434/api",
42
- "OLLAMA_SMALL_MODEL": "gemma3:latest",
43
- "OLLAMA_MEDIUM_MODEL": "gemma3:latest",
44
- "OLLAMA_LARGE_MODEL": "gemma3:latest",
45
- "OLLAMA_EMBEDDING_MODEL": "nomic-embed-text:latest"
46
- }
47
- ```
48
-
49
- Or in `.env` file:
50
-
51
- ```
52
- OLLAMA_API_ENDPOINT=http://localhost:11434/api
53
- OLLAMA_SMALL_MODEL=gemma3:latest
54
- OLLAMA_MEDIUM_MODEL=gemma3:latest
55
- OLLAMA_LARGE_MODEL=gemma3:latest
56
- OLLAMA_EMBEDDING_MODEL=nomic-embed-text:latest
57
- ```
58
-
59
- ### Configuration Options
60
-
61
- - `OLLAMA_API_ENDPOINT`: Ollama API endpoint (default: http://localhost:11434/api)
62
- - `OLLAMA_SMALL_MODEL`: Model for simpler tasks (default: gemma3:latest)
63
- - `OLLAMA_MEDIUM_MODEL`: Medium-complexity model (default: gemma3:latest)
64
- - `OLLAMA_LARGE_MODEL`: Model for complex tasks (default: gemma3:latest)
65
- - `OLLAMA_EMBEDDING_MODEL`: Model for text embeddings (default: nomic-embed-text:latest)
66
-
67
- The plugin provides these model classes:
68
-
69
- - `TEXT_SMALL`: Optimized for fast responses with simpler prompts
70
- - `TEXT_LARGE`: For complex tasks requiring deeper reasoning
71
- - `TEXT_EMBEDDING`: Text embedding model
72
- - `OBJECT_SMALL`: JSON object generation with simpler models
73
- - `OBJECT_LARGE`: JSON object generation with more complex models
74
-
75
- ## API Reference
76
-
77
- For detailed information about the Ollama API used by this plugin, refer to the [official Ollama API documentation](https://github.com/ollama/ollama/blob/main/docs/api.md).
78
-
79
-
80
-
81
- ## Features
82
-
83
- ### Text Generation (Small Model)
84
-
85
- Generate text using smaller, faster models optimized for quick responses:
86
-
87
- ```js
88
- const text = await runtime.useModel(ModelType.TEXT_SMALL, {
89
- prompt: 'What is the nature of reality?',
90
- stopSequences: [], // optional
91
- });
92
- ```
93
-
94
- ### Text Generation (Large Model)
95
-
96
- Generate comprehensive text responses using more powerful models for complex tasks:
97
-
98
- ```js
99
- const text = await runtime.useModel(ModelType.TEXT_LARGE, {
100
- prompt: 'Write a detailed explanation of quantum physics',
101
- stopSequences: [], // optional
102
- maxTokens: 8192, // optional (default: 8192)
103
- temperature: 0.7, // optional (default: 0.7)
104
- frequencyPenalty: 0.7, // optional (default: 0.7)
105
- presencePenalty: 0.7, // optional (default: 0.7)
106
- });
107
- ```
108
-
109
- ### Text Embeddings
110
-
111
- Generate vector embeddings for text, which can be used for semantic search or other vector operations:
112
-
113
- ```js
114
- const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {
115
- text: 'Text to embed',
116
- });
117
- // or
118
- const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, 'Text to embed');
119
- ```
120
-
121
- ### Object Generation (Small Model)
122
-
123
- Generate structured JSON objects using faster models:
124
-
125
- ```js
126
- const object = await runtime.useModel(ModelType.OBJECT_SMALL, {
127
- prompt: 'Generate a JSON object representing a user profile',
128
- temperature: 0.7, // optional
129
- });
130
- ```
131
-
132
- ### Object Generation (Large Model)
133
-
134
- Generate complex, detailed JSON objects using more powerful models:
135
-
136
- ```js
137
- const object = await runtime.useModel(ModelType.OBJECT_LARGE, {
138
- prompt: 'Generate a detailed JSON object representing a restaurant',
139
- temperature: 0.7, // optional
140
- });
141
- ```
142
-
143
- ## Troubleshooting
144
-
145
- ### Connection Issues
146
-
147
- - Ensure Ollama is running by testing the `OLLAMA_API_ENDPOINT`
148
- - Verify the `OLLAMA_API_ENDPOINT` points to the correct host and port
149
- - Check firewall settings if connecting to a remote Ollama instance
150
-
151
- ### Model Availability
152
-
153
- - The plugin will attempt to download models automatically if they're not found
154
- - You can pre-download models using `ollama pull modelname`
155
- - Check model availability with `ollama list`
156
-
157
-
158
- ## License
159
-
160
- See LICENSE file for details.
package/dist/index.js DELETED
@@ -1,356 +0,0 @@
1
- // src/index.ts
2
- import { ModelType, logger } from "@elizaos/core";
3
- import { generateObject, generateText, embed } from "ai";
4
- import { createOllama } from "ollama-ai-provider";
5
- var OLLAMA_API_URL = "http://localhost:11434/api";
6
- function getBaseURL(runtime) {
7
- const apiEndpoint = runtime.getSetting("OLLAMA_API_ENDPOINT") || runtime.getSetting("OLLAMA_API_URL") || OLLAMA_API_URL;
8
- if (!apiEndpoint.endsWith("/api")) {
9
- return apiEndpoint.endsWith("/") ? `${apiEndpoint}api` : `${apiEndpoint}/api`;
10
- }
11
- return apiEndpoint;
12
- }
13
- async function ensureModelAvailable(runtime, model, providedBaseURL) {
14
- const baseURL = providedBaseURL || getBaseURL(runtime);
15
- const apiBase = baseURL.endsWith("/api") ? baseURL.slice(0, -4) : baseURL;
16
- try {
17
- const showRes = await fetch(`${apiBase}/api/show`, {
18
- method: "POST",
19
- headers: { "Content-Type": "application/json" },
20
- body: JSON.stringify({ model })
21
- });
22
- if (showRes.ok) return;
23
- logger.info(`[Ollama] Model ${model} not found locally. Downloading...`);
24
- const pullRes = await fetch(`${apiBase}/api/pull`, {
25
- method: "POST",
26
- headers: { "Content-Type": "application/json" },
27
- body: JSON.stringify({ model, stream: false })
28
- });
29
- if (!pullRes.ok) {
30
- logger.error(`Failed to pull model ${model}: ${pullRes.statusText}`);
31
- } else {
32
- logger.info(`[Ollama] Downloaded model ${model}`);
33
- }
34
- } catch (err) {
35
- logger.error({ error: err }, "Error ensuring model availability");
36
- }
37
- }
38
- async function generateOllamaText(ollama, model, params) {
39
- try {
40
- const { text: ollamaResponse } = await generateText({
41
- model: ollama(model),
42
- prompt: params.prompt,
43
- system: params.system,
44
- temperature: params.temperature,
45
- maxTokens: params.maxTokens,
46
- frequencyPenalty: params.frequencyPenalty,
47
- presencePenalty: params.presencePenalty,
48
- stopSequences: params.stopSequences
49
- });
50
- return ollamaResponse;
51
- } catch (error) {
52
- logger.error({ error }, "Error in generateOllamaText");
53
- return "Error generating text. Please try again later.";
54
- }
55
- }
56
- async function generateOllamaObject(ollama, model, params) {
57
- try {
58
- const { object } = await generateObject({
59
- model: ollama(model),
60
- output: "no-schema",
61
- prompt: params.prompt,
62
- temperature: params.temperature
63
- });
64
- return object;
65
- } catch (error) {
66
- logger.error({ error }, "Error generating object");
67
- return {};
68
- }
69
- }
70
- var ollamaPlugin = {
71
- name: "ollama",
72
- description: "Ollama plugin",
73
- config: {
74
- OLLAMA_API_ENDPOINT: process.env.OLLAMA_API_ENDPOINT,
75
- OLLAMA_SMALL_MODEL: process.env.OLLAMA_SMALL_MODEL,
76
- OLLAMA_MEDIUM_MODEL: process.env.OLLAMA_MEDIUM_MODEL,
77
- OLLAMA_LARGE_MODEL: process.env.OLLAMA_LARGE_MODEL,
78
- OLLAMA_EMBEDDING_MODEL: process.env.OLLAMA_EMBEDDING_MODEL
79
- },
80
- async init(_config, runtime) {
81
- const baseURL = getBaseURL(runtime);
82
- if (!baseURL || baseURL === "http://localhost:11434/api") {
83
- const endpoint = runtime.getSetting("OLLAMA_API_ENDPOINT");
84
- if (!endpoint) {
85
- logger.warn(
86
- "OLLAMA_API_ENDPOINT is not set in environment - Ollama functionality will use default localhost:11434"
87
- );
88
- }
89
- }
90
- try {
91
- const apiBase = baseURL.endsWith("/api") ? baseURL.slice(0, -4) : baseURL;
92
- const response = await fetch(`${apiBase}/api/tags`, {
93
- method: "GET",
94
- headers: { "Content-Type": "application/json" }
95
- });
96
- if (!response.ok) {
97
- logger.warn(`Ollama API endpoint validation failed: ${response.statusText}`);
98
- logger.warn("Ollama functionality will be limited until a valid endpoint is provided");
99
- } else {
100
- const data = await response.json();
101
- const modelCount = data?.models?.length || 0;
102
- logger.log(
103
- `Ollama API endpoint validated successfully. Found ${modelCount} models available.`
104
- );
105
- }
106
- } catch (fetchError) {
107
- const message = fetchError instanceof Error ? fetchError.message : String(fetchError);
108
- logger.warn(`Error validating Ollama API endpoint: ${message}`);
109
- logger.warn(
110
- "Ollama functionality will be limited until a valid endpoint is provided - Make sure Ollama is running at ${baseURL}"
111
- );
112
- }
113
- },
114
- models: {
115
- [ModelType.TEXT_EMBEDDING]: async (runtime, params) => {
116
- try {
117
- const baseURL = getBaseURL(runtime);
118
- const ollama = createOllama({
119
- fetch: runtime.fetch,
120
- baseURL
121
- });
122
- const modelName = runtime.getSetting("OLLAMA_EMBEDDING_MODEL") || "nomic-embed-text:latest";
123
- logger.log(`[Ollama] Using TEXT_EMBEDDING model: ${modelName}`);
124
- await ensureModelAvailable(runtime, modelName, baseURL);
125
- const text = typeof params === "string" ? params : params ? params.text || "" : "";
126
- const embeddingText = text || "test";
127
- if (!text) {
128
- logger.debug(
129
- "No text provided for embedding, using default text for dimension detection"
130
- );
131
- }
132
- try {
133
- const { embedding } = await embed({
134
- model: ollama.embedding(modelName),
135
- value: embeddingText
136
- });
137
- return embedding;
138
- } catch (embeddingError) {
139
- logger.error({ error: embeddingError }, "Error generating embedding");
140
- return Array(1536).fill(0);
141
- }
142
- } catch (error) {
143
- logger.error({ error }, "Error in TEXT_EMBEDDING model");
144
- return Array(1536).fill(0);
145
- }
146
- },
147
- [ModelType.TEXT_SMALL]: async (runtime, { prompt, stopSequences = [] }) => {
148
- try {
149
- const temperature = 0.7;
150
- const frequency_penalty = 0.7;
151
- const presence_penalty = 0.7;
152
- const max_response_length = 8e3;
153
- const baseURL = getBaseURL(runtime);
154
- const ollama = createOllama({
155
- fetch: runtime.fetch,
156
- baseURL
157
- });
158
- const model = runtime.getSetting("OLLAMA_SMALL_MODEL") || runtime.getSetting("SMALL_MODEL") || "gemma3:latest";
159
- logger.log(`[Ollama] Using TEXT_SMALL model: ${model}`);
160
- await ensureModelAvailable(runtime, model, baseURL);
161
- logger.log("generating text");
162
- logger.log(prompt);
163
- return await generateOllamaText(ollama, model, {
164
- prompt,
165
- system: runtime.character?.system || void 0,
166
- temperature,
167
- maxTokens: max_response_length,
168
- frequencyPenalty: frequency_penalty,
169
- presencePenalty: presence_penalty,
170
- stopSequences
171
- });
172
- } catch (error) {
173
- logger.error({ error }, "Error in TEXT_SMALL model");
174
- return "Error generating text. Please try again later.";
175
- }
176
- },
177
- [ModelType.TEXT_LARGE]: async (runtime, {
178
- prompt,
179
- stopSequences = [],
180
- maxTokens = 8192,
181
- temperature = 0.7,
182
- frequencyPenalty = 0.7,
183
- presencePenalty = 0.7
184
- }) => {
185
- try {
186
- const model = runtime.getSetting("OLLAMA_LARGE_MODEL") || runtime.getSetting("LARGE_MODEL") || "gemma3:latest";
187
- const baseURL = getBaseURL(runtime);
188
- const ollama = createOllama({
189
- fetch: runtime.fetch,
190
- baseURL
191
- });
192
- logger.log(`[Ollama] Using TEXT_LARGE model: ${model}`);
193
- await ensureModelAvailable(runtime, model, baseURL);
194
- return await generateOllamaText(ollama, model, {
195
- prompt,
196
- system: runtime.character?.system || void 0,
197
- temperature,
198
- maxTokens,
199
- frequencyPenalty,
200
- presencePenalty,
201
- stopSequences
202
- });
203
- } catch (error) {
204
- logger.error({ error }, "Error in TEXT_LARGE model");
205
- return "Error generating text. Please try again later.";
206
- }
207
- },
208
- [ModelType.OBJECT_SMALL]: async (runtime, params) => {
209
- try {
210
- const baseURL = getBaseURL(runtime);
211
- const ollama = createOllama({
212
- fetch: runtime.fetch,
213
- baseURL
214
- });
215
- const model = runtime.getSetting("OLLAMA_SMALL_MODEL") || runtime.getSetting("SMALL_MODEL") || "gemma3:latest";
216
- logger.log(`[Ollama] Using OBJECT_SMALL model: ${model}`);
217
- await ensureModelAvailable(runtime, model, baseURL);
218
- if (params.schema) {
219
- logger.info("Using OBJECT_SMALL without schema validation");
220
- }
221
- return await generateOllamaObject(ollama, model, params);
222
- } catch (error) {
223
- logger.error({ error }, "Error in OBJECT_SMALL model");
224
- return {};
225
- }
226
- },
227
- [ModelType.OBJECT_LARGE]: async (runtime, params) => {
228
- try {
229
- const baseURL = getBaseURL(runtime);
230
- const ollama = createOllama({
231
- fetch: runtime.fetch,
232
- baseURL
233
- });
234
- const model = runtime.getSetting("OLLAMA_LARGE_MODEL") || runtime.getSetting("LARGE_MODEL") || "gemma3:latest";
235
- logger.log(`[Ollama] Using OBJECT_LARGE model: ${model}`);
236
- await ensureModelAvailable(runtime, model, baseURL);
237
- if (params.schema) {
238
- logger.info("Using OBJECT_LARGE without schema validation");
239
- }
240
- return await generateOllamaObject(ollama, model, params);
241
- } catch (error) {
242
- logger.error({ error }, "Error in OBJECT_LARGE model");
243
- return {};
244
- }
245
- }
246
- },
247
- tests: [
248
- {
249
- name: "ollama_plugin_tests",
250
- tests: [
251
- {
252
- name: "ollama_test_url_validation",
253
- fn: async (runtime) => {
254
- try {
255
- const baseURL = getBaseURL(runtime);
256
- const apiBase = baseURL.endsWith("/api") ? baseURL.slice(0, -4) : baseURL;
257
- const response = await fetch(`${apiBase}/api/tags`);
258
- const data = await response.json();
259
- const modelCount = data && typeof data === "object" && "models" in data && Array.isArray(data.models) ? data.models.length : 0;
260
- logger.log(`Models Available: ${modelCount}`);
261
- if (!response.ok) {
262
- logger.error(`Failed to validate Ollama API: ${response.statusText}`);
263
- return;
264
- }
265
- } catch (error) {
266
- logger.error({ error }, "Error in ollama_test_url_validation");
267
- }
268
- }
269
- },
270
- {
271
- name: "ollama_test_text_embedding",
272
- fn: async (runtime) => {
273
- try {
274
- const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {
275
- text: "Hello, world!"
276
- });
277
- logger.log({ embedding }, "Generated embedding");
278
- } catch (error) {
279
- logger.error({ error }, "Error in test_text_embedding");
280
- }
281
- }
282
- },
283
- {
284
- name: "ollama_test_text_large",
285
- fn: async (runtime) => {
286
- try {
287
- const text = await runtime.useModel(ModelType.TEXT_LARGE, {
288
- prompt: "What is the nature of reality in 10 words?"
289
- });
290
- if (text.length === 0) {
291
- logger.error("Failed to generate text");
292
- return;
293
- }
294
- logger.log({ text }, "Generated with test_text_large");
295
- } catch (error) {
296
- logger.error({ error }, "Error in test_text_large");
297
- }
298
- }
299
- },
300
- {
301
- name: "ollama_test_text_small",
302
- fn: async (runtime) => {
303
- try {
304
- const text = await runtime.useModel(ModelType.TEXT_SMALL, {
305
- prompt: "What is the nature of reality in 10 words?"
306
- });
307
- if (text.length === 0) {
308
- logger.error("Failed to generate text");
309
- return;
310
- }
311
- logger.log({ text }, "Generated with test_text_small");
312
- } catch (error) {
313
- logger.error({ error }, "Error in test_text_small");
314
- }
315
- }
316
- },
317
- {
318
- name: "ollama_test_object_small",
319
- fn: async (runtime) => {
320
- try {
321
- const object = await runtime.useModel(ModelType.OBJECT_SMALL, {
322
- prompt: "Generate a JSON object representing a user profile with name, age, and hobbies",
323
- temperature: 0.7,
324
- schema: void 0
325
- });
326
- logger.log({ object }, "Generated object");
327
- } catch (error) {
328
- logger.error({ error }, "Error in test_object_small");
329
- }
330
- }
331
- },
332
- {
333
- name: "ollama_test_object_large",
334
- fn: async (runtime) => {
335
- try {
336
- const object = await runtime.useModel(ModelType.OBJECT_LARGE, {
337
- prompt: "Generate a detailed JSON object representing a restaurant with name, cuisine type, menu items with prices, and customer reviews",
338
- temperature: 0.7,
339
- schema: void 0
340
- });
341
- logger.log({ object }, "Generated object");
342
- } catch (error) {
343
- logger.error({ error }, "Error in test_object_large");
344
- }
345
- }
346
- }
347
- ]
348
- }
349
- ]
350
- };
351
- var index_default = ollamaPlugin;
352
- export {
353
- index_default as default,
354
- ollamaPlugin
355
- };
356
- //# sourceMappingURL=index.js.map