ai-sdk-ollama 4.6.5 → 4.7.0
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 +13 -0
- package/README.md +43 -0
- package/dist/index.browser.cjs +3510 -3454
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +3513 -3453
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +20423 -20377
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20422 -20372
- package/dist/index.js.map +1 -1
- package/dist/models/chat-request.d.ts +9 -8
- package/dist/models/chat-request.d.ts.map +1 -1
- package/dist/provider-options.d.ts +41 -0
- package/dist/provider-options.d.ts.map +1 -0
- package/dist/provider.browser.d.ts.map +1 -1
- package/dist/provider.d.ts +13 -35
- package/dist/provider.d.ts.map +1 -1
- package/dist/utils/convert-to-ollama-messages.d.ts +1 -4
- package/dist/utils/convert-to-ollama-messages.d.ts.map +1 -1
- package/package.json +12 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4ed9b84: Add Ollama `think` levels, per-call keep-alive and field extraction.
|
|
8
|
+
|
|
9
|
+
- `providerOptions.ollama.think` takes `true`, `false`, `'low'`, `'medium'`, `'high'` or `'max'`, and wins over `reasoning` and the model's `think` setting.
|
|
10
|
+
- `reasoning: 'xhigh'` sends `think: 'max'`.
|
|
11
|
+
- `providerOptions.ollama.keepAlive` sets `keep_alive` for one call.
|
|
12
|
+
- `ollama.extractionModel()` supports `experimental_extract` from `ai` 7.1.
|
|
13
|
+
- Non-image files in user messages and tool results throw `UnsupportedFunctionalityError`, since Ollama chat reads images only.
|
|
14
|
+
- Dependencies updated.
|
|
15
|
+
|
|
3
16
|
## 4.6.5
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -322,6 +322,13 @@ const { text } = await generateText({
|
|
|
322
322
|
model,
|
|
323
323
|
prompt: 'Write a haiku',
|
|
324
324
|
});
|
|
325
|
+
|
|
326
|
+
// Or per call, overriding the model setting
|
|
327
|
+
await generateText({
|
|
328
|
+
model,
|
|
329
|
+
prompt: 'Write a haiku',
|
|
330
|
+
providerOptions: { ollama: { keepAlive: '1h' } },
|
|
331
|
+
});
|
|
325
332
|
```
|
|
326
333
|
|
|
327
334
|
**Accepted values:**
|
|
@@ -1011,6 +1018,25 @@ const { output: custom } = await generateText({
|
|
|
1011
1018
|
});
|
|
1012
1019
|
```
|
|
1013
1020
|
|
|
1021
|
+
### Field Extraction (experimental)
|
|
1022
|
+
|
|
1023
|
+
`ollama.extractionModel()` works with `experimental_extract` from `ai` 7.1+. It runs on any chat model through structured outputs. State accepts text, JSON and images. Ollama chat reads images only, so other file types throw `UnsupportedFunctionalityError`.
|
|
1024
|
+
|
|
1025
|
+
```typescript
|
|
1026
|
+
import { experimental_extract } from 'ai';
|
|
1027
|
+
import { ollama } from 'ai-sdk-ollama';
|
|
1028
|
+
|
|
1029
|
+
const { answers } = await experimental_extract({
|
|
1030
|
+
model: ollama.extractionModel('qwen3.5:4b'),
|
|
1031
|
+
state: 'Invoice INV-2041 from Acme. Total due $1,250.00 by March 3.',
|
|
1032
|
+
fields: {
|
|
1033
|
+
invoiceNumber: { type: 'text', instructions: 'The invoice number' },
|
|
1034
|
+
total: { type: 'number', instructions: 'Total amount due', decimals: 2 },
|
|
1035
|
+
dueDate: { type: 'date', instructions: 'Payment due date' },
|
|
1036
|
+
},
|
|
1037
|
+
});
|
|
1038
|
+
```
|
|
1039
|
+
|
|
1014
1040
|
### Reasoning Support
|
|
1015
1041
|
|
|
1016
1042
|
Use `think` to request reasoning generation from models that support it. Returned `message.thinking` is exposed as AI SDK reasoning, separately from final text, in both generation results and streams (including terminal chunks).
|
|
@@ -1041,6 +1067,23 @@ const { text: noReasoningText } = await generateText({
|
|
|
1041
1067
|
console.log('Answer:', noReasoningText);
|
|
1042
1068
|
```
|
|
1043
1069
|
|
|
1070
|
+
`think` also accepts a level: `'low'`, `'medium'`, `'high'` or `'max'`. Levels need Ollama 0.17.7+ for models other than gpt-oss, and `'max'` needs 0.22.0+. On older servers, pass `think: true`. Each model decides what a level does, and some treat every level as `true`.
|
|
1071
|
+
|
|
1072
|
+
```typescript
|
|
1073
|
+
// Per call, overriding the model setting
|
|
1074
|
+
await generateText({
|
|
1075
|
+
model,
|
|
1076
|
+
prompt: 'Prove there are infinitely many primes',
|
|
1077
|
+
providerOptions: { ollama: { think: 'max' } },
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
// The AI SDK's portable `reasoning` option maps to a level:
|
|
1081
|
+
// none → false, minimal/low → 'low', medium → 'medium', high → 'high', xhigh → 'max'
|
|
1082
|
+
await generateText({ model, prompt: '...', reasoning: 'xhigh' });
|
|
1083
|
+
```
|
|
1084
|
+
|
|
1085
|
+
Precedence: `providerOptions.ollama.think`, then `reasoning`, then the model's `think` setting.
|
|
1086
|
+
|
|
1044
1087
|
`think` controls the request, not filtering of the response. If the server returns thinking with `think` omitted or `false`, the adapter still preserves it as reasoning; it does not turn it into final text. If no thinking is returned, no reasoning content is added.
|
|
1045
1088
|
|
|
1046
1089
|
Ollama supplies a combined output token count. The adapter preserves that total and the raw counters, but leaves the text/reasoning token breakdown unknown instead of attributing all output tokens to text.
|