ai-sdk-ollama 4.4.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 CHANGED
@@ -1,5 +1,16 @@
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
+
3
14
  ## 4.4.0
4
15
 
5
16
  ### Minor Changes
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('qwen3-coder:480b-cloud'), // Cloud models recommended for web search
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
- - `qwen3-coder:480b-cloud` - Best for general web search
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
@@ -484,14 +484,14 @@ ranking.forEach((item, i) => {
484
484
 
485
485
  ## Decision Models
486
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`:
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
488
 
489
489
  ```typescript
490
- import { experimental_evaluate as evaluate } from 'ai';
490
+ import { experimental_decide as decide } from 'ai';
491
491
  import { ollama } from 'ai-sdk-ollama';
492
492
 
493
- const { answers } = await evaluate({
494
- model: ollama.evaluationModel('nimble'),
493
+ const { answers } = await decide({
494
+ model: ollama.decisionModel('nimble'),
495
495
  state: { ticket: 'I was charged twice. Please refund the extra payment.' },
496
496
  questions: {
497
497
  team: {
@@ -1043,7 +1043,7 @@ Works with any model in your Ollama installation:
1043
1043
  - **Vision**: `llava`, `bakllava`, `llama3.2-vision`, `minicpm-v`
1044
1044
  - **Embeddings**: `nomic-embed-text`, `all-minilm`, `mxbai-embed-large`
1045
1045
  - **Reasoning**: `deepseek-r1:7b`, `deepseek-r1:1.5b`, `deepseek-r1:8b`
1046
- - **Cloud Models** (for web search): `qwen3-coder:480b-cloud`, `gpt-oss:120b-cloud`
1046
+ - **Cloud Models** (for web search): `deepseek-v4.1-flash:cloud`, `gpt-oss:120b-cloud`
1047
1047
 
1048
1048
  ## Testing
1049
1049
 
@@ -22,6 +22,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22
22
  // src/index.browser.ts
23
23
  var index_browser_exports = {};
24
24
  __export(index_browser_exports, {
25
+ OllamaDecisionModel: () => OllamaDecisionModel,
25
26
  OllamaError: () => OllamaError,
26
27
  OllamaEvaluationModel: () => OllamaEvaluationModel,
27
28
  OllamaRerankingModel: () => OllamaRerankingModel,
@@ -22718,12 +22719,36 @@ var OllamaImageModel = class {
22718
22719
  }
22719
22720
  };
22720
22721
 
22721
- // src/models/evaluation-model.ts
22722
+ // src/models/decision-model.ts
22723
+ var import_provider = require("@ai-sdk/provider");
22722
22724
  var isList = (input2) => Array.isArray(input2);
22723
22725
  var isText = (input2) => typeof input2 === "string";
22724
22726
  var toContent = (input2) => isList(input2) ? [...input2] : input2;
22725
22727
  var describe3 = (input2) => isText(input2) ? input2 : JSON.stringify(input2);
22726
22728
  var describeOptional = (input2) => input2 == null ? void 0 : describe3(input2);
22729
+ function toStateValue(part) {
22730
+ switch (part.type) {
22731
+ case "text": {
22732
+ return part.text;
22733
+ }
22734
+ case "json": {
22735
+ return part.value;
22736
+ }
22737
+ case "file": {
22738
+ throw new import_provider.UnsupportedFunctionalityError({
22739
+ functionality: "file parts in decision state"
22740
+ });
22741
+ }
22742
+ }
22743
+ }
22744
+ function toState(state) {
22745
+ const values = state.map(toStateValue);
22746
+ const [only] = values;
22747
+ if (values.length === 1 && only != null && typeof only !== "number" && typeof only !== "boolean") {
22748
+ return toContent(only);
22749
+ }
22750
+ return values;
22751
+ }
22727
22752
  function toSystemOneQuestion(question) {
22728
22753
  const instructions = toContent(question.instructions);
22729
22754
  switch (question.type) {
@@ -22760,7 +22785,7 @@ function toSystemOneQuestion(question) {
22760
22785
  }
22761
22786
  }
22762
22787
  }
22763
- var OllamaEvaluationModel = class {
22788
+ var OllamaDecisionModel = class {
22764
22789
  constructor(modelId, config2) {
22765
22790
  __publicField(this, "modelId", modelId);
22766
22791
  __publicField(this, "config", config2);
@@ -22770,7 +22795,7 @@ var OllamaEvaluationModel = class {
22770
22795
  get provider() {
22771
22796
  return this.config.provider;
22772
22797
  }
22773
- async doEvaluate({
22798
+ async doDecide({
22774
22799
  state,
22775
22800
  questions,
22776
22801
  abortSignal
@@ -22778,12 +22803,12 @@ var OllamaEvaluationModel = class {
22778
22803
  const { client } = this.config;
22779
22804
  if (!client.systemone) {
22780
22805
  throw new OllamaError({
22781
- message: "The configured Ollama client does not implement systemone(); evaluation models need ollama >= 0.6.4 or an adapter that provides it."
22806
+ message: "The configured Ollama client does not implement systemone(); decision models need ollama >= 0.6.4 or an adapter that provides it."
22782
22807
  });
22783
22808
  }
22784
22809
  const request = {
22785
22810
  model: this.modelId,
22786
- state: toContent(state),
22811
+ state: toState(state),
22787
22812
  questions: Object.fromEntries(
22788
22813
  Object.entries(questions).map(([id, question]) => [
22789
22814
  id,
@@ -22838,6 +22863,7 @@ var OllamaEvaluationModel = class {
22838
22863
  };
22839
22864
  }
22840
22865
  };
22866
+ var OllamaEvaluationModel = OllamaDecisionModel;
22841
22867
 
22842
22868
  // src/tool/web-search.ts
22843
22869
  var import_ai = require("ai");
@@ -23132,10 +23158,11 @@ function createOllama(options = {}) {
23132
23158
  fetch: options.fetch
23133
23159
  });
23134
23160
  provider.imageModel = createImageModel;
23135
- provider.evaluationModel = (modelId) => new OllamaEvaluationModel(modelId, {
23161
+ provider.decisionModel = (modelId) => new OllamaDecisionModel(modelId, {
23136
23162
  client,
23137
- provider: "ollama.evaluation"
23163
+ provider: "ollama.decision"
23138
23164
  });
23165
+ provider.evaluationModel = provider.decisionModel;
23139
23166
  const toolsWithClient = {
23140
23167
  webSearch: (options2 = {}) => ollamaTools.webSearch({ ...options2, client }),
23141
23168
  webFetch: (options2 = {}) => ollamaTools.webFetch({ ...options2, client })