ai-sdk-ollama 4.3.0 → 4.5.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 +23 -1
- package/README.md +46 -6
- package/dist/functions/generate-text.d.ts.map +1 -1
- package/dist/functions/stream-text.d.ts.map +1 -1
- package/dist/index.browser.cjs +1903 -937
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +1905 -937
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1912 -942
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1912 -942
- package/dist/index.js.map +1 -1
- package/dist/models/chat-language-model.d.ts +6 -0
- package/dist/models/chat-language-model.d.ts.map +1 -1
- package/dist/models/chat-language-model.test-helpers.d.ts +2 -0
- package/dist/models/chat-language-model.test-helpers.d.ts.map +1 -1
- package/dist/models/decision-model.d.ts +25 -0
- package/dist/models/decision-model.d.ts.map +1 -0
- package/dist/ollama-client.d.ts +6 -4
- package/dist/ollama-client.d.ts.map +1 -1
- package/dist/provider.browser.d.ts.map +1 -1
- package/dist/provider.d.ts +10 -8
- package/dist/provider.d.ts.map +1 -1
- package/dist/tool/web-fetch.d.ts +4 -0
- package/dist/tool/web-fetch.d.ts.map +1 -1
- package/dist/tool/web-search.d.ts +4 -0
- package/dist/tool/web-search.d.ts.map +1 -1
- package/dist/utils/json-schema-coercion.d.ts +3 -4
- package/dist/utils/json-schema-coercion.d.ts.map +1 -1
- package/dist/utils/json-text-repair.d.ts +9 -6
- package/dist/utils/json-text-repair.d.ts.map +1 -1
- package/dist/utils/last-user-text.d.ts +7 -0
- package/dist/utils/last-user-text.d.ts.map +1 -0
- package/dist/utils/object-generation-reliability.d.ts +3 -4
- package/dist/utils/object-generation-reliability.d.ts.map +1 -1
- package/dist/utils/ollama-error.d.ts +2 -0
- package/dist/utils/ollama-error.d.ts.map +1 -1
- package/package.json +17 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c81f4d4: Track AI SDK 7.0.137 and adopt its `experimental_decide` API for Ollama decision models.
|
|
8
|
+
|
|
9
|
+
- `ollama.decisionModel()` returns an `OllamaDecisionModel` that implements `DecisionModelV4` with `doDecide`. `evaluationModel()` and `OllamaEvaluationModel` stay as deprecated aliases.
|
|
10
|
+
- Decision state accepts text and JSON parts. A single part goes to Ollama as-is, and several parts go as a list.
|
|
11
|
+
- The `ai` peer range moves to `^7.0.137`, with `@ai-sdk/provider` and `@ai-sdk/provider-utils` updated to match.
|
|
12
|
+
- Web search docs, examples and tests use `deepseek-v4.1-flash:cloud` alongside `gpt-oss:120b-cloud`.
|
|
13
|
+
|
|
14
|
+
## 4.4.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 004f6b4: Add `ollama.evaluationModel()` for Ollama decision models such as `nimble` and `tev1`. Use it with the AI SDK's `experimental_evaluate` to get typed choice, boolean and score answers with probabilities from one local call.
|
|
19
|
+
|
|
20
|
+
- `OllamaClient` accepts an optional `systemone()` method.
|
|
21
|
+
- `generateText` and `streamText` restate the latest user message, text parts included, when they synthesise a reply from tool results.
|
|
22
|
+
- JSON repair serialises object values for string fields as JSON.
|
|
23
|
+
- Supports `ai` 7.0.103+ and `ollama` 0.6.4.
|
|
24
|
+
|
|
3
25
|
## 4.3.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -7,7 +29,7 @@
|
|
|
7
29
|
- 371f515: Track AI SDK 7.0.95 and open the provider up to custom Ollama clients.
|
|
8
30
|
|
|
9
31
|
- The `ai` peer range moves to `^7.0.95`, with `@ai-sdk/provider` and `@ai-sdk/provider-utils` updated to match.
|
|
10
|
-
- `OllamaClient` is a structural contract, so the official client
|
|
32
|
+
- `OllamaClient` is a structural contract, so the official client or a custom adapter can be injected in both Node.js and browser builds. Streaming methods use the newly exported `AbortableStream` type.
|
|
11
33
|
- Per-request `AbortSignal`s are forwarded to the client, and an aborted request settles as a rejection across the reliability retry and fallback paths.
|
|
12
34
|
- Returned `message.thinking` is surfaced as AI SDK reasoning independently of the request's `think` setting, including on terminal stream chunks, and streamed text and reasoning blocks close symmetrically.
|
|
13
35
|
- Output usage carries the total token count Ollama reports and leaves the text/reasoning split unset, matching what the API provides.
|
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ import { ollama } from 'ai-sdk-ollama';
|
|
|
91
91
|
|
|
92
92
|
// 🔍 Web search for current information
|
|
93
93
|
const { text } = await generateText({
|
|
94
|
-
model: ollama('
|
|
94
|
+
model: ollama('deepseek-v4.1-flash:cloud'), // Cloud models recommended for web search
|
|
95
95
|
prompt: 'What are the latest developments in AI this week?',
|
|
96
96
|
tools: {
|
|
97
97
|
webSearch: ollama.tools.webSearch({ maxResults: 5 }),
|
|
@@ -122,7 +122,7 @@ const { text: research } = await generateText({
|
|
|
122
122
|
|
|
123
123
|
1. **Ollama API Key**: Set `OLLAMA_API_KEY` environment variable
|
|
124
124
|
2. **Cloud Models**: Use cloud models for optimal web search performance:
|
|
125
|
-
- `
|
|
125
|
+
- `deepseek-v4.1-flash:cloud` - Best for general web search
|
|
126
126
|
- `gpt-oss:120b-cloud` - Best for complex reasoning with web data
|
|
127
127
|
|
|
128
128
|
```bash
|
|
@@ -154,6 +154,7 @@ export OLLAMA_API_KEY="your_api_key_here"
|
|
|
154
154
|
- [Combining Tools with Structured Output](#combining-tools-with-structured-output)
|
|
155
155
|
- [Simple and Predictable](#simple-and-predictable)
|
|
156
156
|
- [Reranking](#reranking)
|
|
157
|
+
- [Decision Models](#decision-models)
|
|
157
158
|
- [Streaming Utilities](#streaming-utilities)
|
|
158
159
|
- [Smooth Stream](#smooth-stream)
|
|
159
160
|
- [Partial JSON Parsing](#partial-json-parsing)
|
|
@@ -481,6 +482,46 @@ ranking.forEach((item, i) => {
|
|
|
481
482
|
|
|
482
483
|
**Recommended Models**: `embeddinggemma` (best score separation), `nomic-embed-text`, `bge-m3`
|
|
483
484
|
|
|
485
|
+
## Decision Models
|
|
486
|
+
|
|
487
|
+
Ollama 0.35 serves decision models (`nimble`, `tev1`, `tev1:0.8b`) on `/v1/systemone`. You ask typed questions about some state and get each answer with its probabilities in one local call. Use them for triage, routing and moderation through the AI SDK's `experimental_decide`:
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
import { experimental_decide as decide } from 'ai';
|
|
491
|
+
import { ollama } from 'ai-sdk-ollama';
|
|
492
|
+
|
|
493
|
+
const { answers } = await decide({
|
|
494
|
+
model: ollama.decisionModel('nimble'),
|
|
495
|
+
state: { ticket: 'I was charged twice. Please refund the extra payment.' },
|
|
496
|
+
questions: {
|
|
497
|
+
team: {
|
|
498
|
+
type: 'choice',
|
|
499
|
+
instructions: 'Which team should handle this ticket?',
|
|
500
|
+
criteria: {
|
|
501
|
+
billing: 'Payments and refunds',
|
|
502
|
+
technical: null,
|
|
503
|
+
other: null,
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
refund: {
|
|
507
|
+
type: 'boolean',
|
|
508
|
+
instructions: 'Does the customer ask for a refund?',
|
|
509
|
+
},
|
|
510
|
+
urgency: {
|
|
511
|
+
type: 'score',
|
|
512
|
+
instructions: 'How urgent is this ticket?',
|
|
513
|
+
criteria: ['Routine', 'Soon', 'Urgent'],
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
answers.team.choice; // 'billing'
|
|
519
|
+
answers.refund.probability; // P(true), e.g. 0.99
|
|
520
|
+
answers.urgency.score; // 0 to 2, e.g. 0.8
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
Ollama names boolean questions `noul`, and the provider maps them for you. Ollama's per-question `confidence` lands in `providerMetadata.ollama.confidence`. Pull a model first with `ollama pull nimble`.
|
|
524
|
+
|
|
484
525
|
## Streaming Utilities
|
|
485
526
|
|
|
486
527
|
### Smooth Stream
|
|
@@ -741,9 +782,8 @@ const ollama = createOllama({ apiKey: process.env.OLLAMA_API_KEY });
|
|
|
741
782
|
### Using Existing Ollama Client
|
|
742
783
|
|
|
743
784
|
You can also pass an existing Ollama client instance to reuse your configuration.
|
|
744
|
-
The provider accepts the exported structural `OllamaClient` interface, so
|
|
745
|
-
|
|
746
|
-
injected in Node.js and browser builds.
|
|
785
|
+
The provider accepts the exported structural `OllamaClient` interface, so you
|
|
786
|
+
can inject the official client or a custom adapter in Node.js and browser builds.
|
|
747
787
|
|
|
748
788
|
```typescript
|
|
749
789
|
import { Ollama } from 'ollama';
|
|
@@ -1003,7 +1043,7 @@ Works with any model in your Ollama installation:
|
|
|
1003
1043
|
- **Vision**: `llava`, `bakllava`, `llama3.2-vision`, `minicpm-v`
|
|
1004
1044
|
- **Embeddings**: `nomic-embed-text`, `all-minilm`, `mxbai-embed-large`
|
|
1005
1045
|
- **Reasoning**: `deepseek-r1:7b`, `deepseek-r1:1.5b`, `deepseek-r1:8b`
|
|
1006
|
-
- **Cloud Models** (for web search): `
|
|
1046
|
+
- **Cloud Models** (for web search): `deepseek-v4.1-flash:cloud`, `gpt-oss:120b-cloud`
|
|
1007
1047
|
|
|
1008
1048
|
## Testing
|
|
1009
1049
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-text.d.ts","sourceRoot":"","sources":["../../src/functions/generate-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,IAAI,aAAa,EAAe,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-text.d.ts","sourceRoot":"","sources":["../../src/functions/generate-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,IAAI,aAAa,EAAe,MAAM,IAAI,CAAC;AAsBhE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;;;OAWG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG;IACtE;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAyNpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-text.d.ts","sourceRoot":"","sources":["../../src/functions/stream-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,WAAW,EAAe,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"stream-text.d.ts","sourceRoot":"","sources":["../../src/functions/stream-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,WAAW,EAAe,MAAM,IAAI,CAAC;AAG5D,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAsC7D,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG;IACpD,eAAe,CAAC,EAAE;QAChB;;WAEG;QACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B;;WAEG;QACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC;;WAEG;QACH,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB;;WAEG;QACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,CAAC;AAUF,wBAAsB,UAAU,CAC9B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAkclD"}
|