ai-sdk-ollama 4.3.0 → 4.4.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/README.md +43 -3
  3. package/dist/functions/generate-text.d.ts.map +1 -1
  4. package/dist/functions/stream-text.d.ts.map +1 -1
  5. package/dist/index.browser.cjs +1876 -937
  6. package/dist/index.browser.cjs.map +1 -1
  7. package/dist/index.browser.d.ts +1 -0
  8. package/dist/index.browser.d.ts.map +1 -1
  9. package/dist/index.browser.js +1876 -937
  10. package/dist/index.browser.js.map +1 -1
  11. package/dist/index.cjs +1884 -942
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1883 -942
  16. package/dist/index.js.map +1 -1
  17. package/dist/models/chat-language-model.d.ts +6 -0
  18. package/dist/models/chat-language-model.d.ts.map +1 -1
  19. package/dist/models/chat-language-model.test-helpers.d.ts +2 -0
  20. package/dist/models/chat-language-model.test-helpers.d.ts.map +1 -1
  21. package/dist/models/evaluation-model.d.ts +21 -0
  22. package/dist/models/evaluation-model.d.ts.map +1 -0
  23. package/dist/ollama-client.d.ts +6 -4
  24. package/dist/ollama-client.d.ts.map +1 -1
  25. package/dist/provider.browser.d.ts.map +1 -1
  26. package/dist/provider.d.ts +8 -8
  27. package/dist/provider.d.ts.map +1 -1
  28. package/dist/tool/web-fetch.d.ts +4 -0
  29. package/dist/tool/web-fetch.d.ts.map +1 -1
  30. package/dist/tool/web-search.d.ts +4 -0
  31. package/dist/tool/web-search.d.ts.map +1 -1
  32. package/dist/utils/json-schema-coercion.d.ts +3 -4
  33. package/dist/utils/json-schema-coercion.d.ts.map +1 -1
  34. package/dist/utils/json-text-repair.d.ts +9 -6
  35. package/dist/utils/json-text-repair.d.ts.map +1 -1
  36. package/dist/utils/last-user-text.d.ts +7 -0
  37. package/dist/utils/last-user-text.d.ts.map +1 -0
  38. package/dist/utils/object-generation-reliability.d.ts +3 -4
  39. package/dist/utils/object-generation-reliability.d.ts.map +1 -1
  40. package/dist/utils/ollama-error.d.ts +2 -0
  41. package/dist/utils/ollama-error.d.ts.map +1 -1
  42. package/package.json +16 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+
9
+ - `OllamaClient` accepts an optional `systemone()` method.
10
+ - `generateText` and `streamText` restate the latest user message, text parts included, when they synthesise a reply from tool results.
11
+ - JSON repair serialises object values for string fields as JSON.
12
+ - Supports `ai` 7.0.103+ and `ollama` 0.6.4.
13
+
3
14
  ## 4.3.0
4
15
 
5
16
  ### Minor Changes
@@ -7,7 +18,7 @@
7
18
  - 371f515: Track AI SDK 7.0.95 and open the provider up to custom Ollama clients.
8
19
 
9
20
  - 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, a maintained fork, or a custom adapter can be injected in both Node.js and browser builds. Streaming methods use the newly exported `AbortableStream` type.
21
+ - `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
22
  - 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
23
  - 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
24
  - 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
@@ -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_evaluate`:
488
+
489
+ ```typescript
490
+ import { experimental_evaluate as evaluate } from 'ai';
491
+ import { ollama } from 'ai-sdk-ollama';
492
+
493
+ const { answers } = await evaluate({
494
+ model: ollama.evaluationModel('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 the
745
- official client, the maintained compatibility fork, or a custom adapter can be
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';
@@ -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;AAqBhE;;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,CA4NpD"}
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;AAC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