ai-sdk-ollama 3.8.6 → 3.8.8
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 +20 -0
- package/dist/index.browser.cjs +60 -21
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +1 -1
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.js +60 -21
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +60 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +60 -15
- package/dist/index.js.map +1 -1
- package/package.json +30 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.8.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b4dde41: Return AI SDK `tool-calls` finish reasons when Ollama responses emit tool calls.
|
|
8
|
+
|
|
9
|
+
## 3.8.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 40cf495: chore: update dependencies + migrate to vite 8
|
|
14
|
+
|
|
15
|
+
Minor/patch dependency refresh via npm-check-updates (--target minor, 3-day cooldown) — no major bumps. Forced vite ^8 and pinned turbo via pnpm override.
|
|
16
|
+
|
|
17
|
+
## 3.8.4
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 6f81c5d: Updated ai-sdk to v6.0.177
|
|
22
|
+
|
|
3
23
|
## 3.8.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.browser.cjs
CHANGED
|
@@ -525,7 +525,13 @@ function convertToOllamaChatMessages(prompt) {
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
// src/utils/map-ollama-finish-reason.ts
|
|
528
|
-
function mapOllamaFinishReason(reason) {
|
|
528
|
+
function mapOllamaFinishReason(reason, hasToolCalls = false) {
|
|
529
|
+
if (hasToolCalls) {
|
|
530
|
+
return {
|
|
531
|
+
unified: "tool-calls",
|
|
532
|
+
raw: reason || void 0
|
|
533
|
+
};
|
|
534
|
+
}
|
|
529
535
|
if (!reason) {
|
|
530
536
|
return {
|
|
531
537
|
unified: "stop",
|
|
@@ -576,6 +582,28 @@ var OllamaError = class _OllamaError extends Error {
|
|
|
576
582
|
// src/utils/object-generation-reliability.ts
|
|
577
583
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
578
584
|
var import_jsonrepair2 = require("jsonrepair");
|
|
585
|
+
var WHITESPACE_CHARS = /* @__PURE__ */ new Set([" ", " ", "\n"]);
|
|
586
|
+
var STRUCTURAL_CLOSE_CHARS = /* @__PURE__ */ new Set(["}", "]"]);
|
|
587
|
+
var KEY_START_CHARS = /* @__PURE__ */ new Set(['"', "\u201C", "_", "$"]);
|
|
588
|
+
var VALUE_START_CHARS = /* @__PURE__ */ new Set([
|
|
589
|
+
'"',
|
|
590
|
+
"\u201C",
|
|
591
|
+
"{",
|
|
592
|
+
"[",
|
|
593
|
+
"-",
|
|
594
|
+
"t",
|
|
595
|
+
"T",
|
|
596
|
+
"f",
|
|
597
|
+
"F",
|
|
598
|
+
"n",
|
|
599
|
+
"N"
|
|
600
|
+
]);
|
|
601
|
+
var SMART_SINGLE_QUOTE_CHARS = /* @__PURE__ */ new Set([
|
|
602
|
+
"\u2018",
|
|
603
|
+
"\u2019",
|
|
604
|
+
"`",
|
|
605
|
+
"\xB4"
|
|
606
|
+
]);
|
|
579
607
|
function isZodSchema(schema) {
|
|
580
608
|
return typeof schema === "object" && schema !== null && "parse" in schema && typeof schema.parse === "function";
|
|
581
609
|
}
|
|
@@ -926,11 +954,14 @@ function replaceSmartQuotesOutsideStrings(text) {
|
|
|
926
954
|
let j = i + 1;
|
|
927
955
|
while (j < text.length) {
|
|
928
956
|
const nextChar = text[j];
|
|
929
|
-
if (nextChar
|
|
957
|
+
if (!nextChar) {
|
|
958
|
+
break;
|
|
959
|
+
}
|
|
960
|
+
if (WHITESPACE_CHARS.has(nextChar)) {
|
|
930
961
|
j++;
|
|
931
962
|
continue;
|
|
932
963
|
}
|
|
933
|
-
if (nextChar
|
|
964
|
+
if (STRUCTURAL_CLOSE_CHARS.has(nextChar)) {
|
|
934
965
|
isClosing = true;
|
|
935
966
|
break;
|
|
936
967
|
}
|
|
@@ -941,18 +972,21 @@ function replaceSmartQuotesOutsideStrings(text) {
|
|
|
941
972
|
if (!afterComma) {
|
|
942
973
|
break;
|
|
943
974
|
}
|
|
944
|
-
if (afterComma
|
|
975
|
+
if (WHITESPACE_CHARS.has(afterComma)) {
|
|
945
976
|
k++;
|
|
946
977
|
continue;
|
|
947
978
|
}
|
|
948
|
-
if (afterComma
|
|
979
|
+
if (KEY_START_CHARS.has(afterComma) || afterComma >= "a" && afterComma <= "z" || afterComma >= "A" && afterComma <= "Z") {
|
|
949
980
|
isClosing = true;
|
|
950
981
|
break;
|
|
951
982
|
} else if (afterComma >= "0" && afterComma <= "9") {
|
|
952
983
|
let m = k + 1;
|
|
953
984
|
while (m < text.length) {
|
|
954
985
|
const afterDigit = text[m];
|
|
955
|
-
if (afterDigit
|
|
986
|
+
if (!afterDigit) {
|
|
987
|
+
break;
|
|
988
|
+
}
|
|
989
|
+
if (WHITESPACE_CHARS.has(afterDigit)) {
|
|
956
990
|
m++;
|
|
957
991
|
continue;
|
|
958
992
|
}
|
|
@@ -979,12 +1013,11 @@ function replaceSmartQuotesOutsideStrings(text) {
|
|
|
979
1013
|
if (!afterColon) {
|
|
980
1014
|
break;
|
|
981
1015
|
}
|
|
982
|
-
if (afterColon
|
|
1016
|
+
if (WHITESPACE_CHARS.has(afterColon)) {
|
|
983
1017
|
k++;
|
|
984
1018
|
continue;
|
|
985
1019
|
}
|
|
986
|
-
if (afterColon
|
|
987
|
-
afterColon === "{" || afterColon === "[" || afterColon >= "0" && afterColon <= "9" || afterColon === "-" || afterColon === "t" || afterColon === "T" || afterColon === "f" || afterColon === "F" || afterColon === "n" || afterColon === "N") {
|
|
1020
|
+
if (VALUE_START_CHARS.has(afterColon) || afterColon >= "0" && afterColon <= "9") {
|
|
988
1021
|
isClosing = true;
|
|
989
1022
|
}
|
|
990
1023
|
break;
|
|
@@ -1003,7 +1036,7 @@ function replaceSmartQuotesOutsideStrings(text) {
|
|
|
1003
1036
|
}
|
|
1004
1037
|
}
|
|
1005
1038
|
if (!inSingleQuote && !inDoubleQuote && !inSmartDoubleQuote) {
|
|
1006
|
-
if (char
|
|
1039
|
+
if (char !== void 0 && SMART_SINGLE_QUOTE_CHARS.has(char)) {
|
|
1007
1040
|
result += "'";
|
|
1008
1041
|
i++;
|
|
1009
1042
|
continue;
|
|
@@ -1581,9 +1614,9 @@ function getLatestUserPromptText(prompt) {
|
|
|
1581
1614
|
}
|
|
1582
1615
|
var OllamaChatLanguageModel = class {
|
|
1583
1616
|
constructor(modelId, settings, config2) {
|
|
1584
|
-
this
|
|
1585
|
-
this
|
|
1586
|
-
this
|
|
1617
|
+
__publicField(this, "modelId", modelId);
|
|
1618
|
+
__publicField(this, "settings", settings);
|
|
1619
|
+
__publicField(this, "config", config2);
|
|
1587
1620
|
__publicField(this, "specificationVersion", "v3");
|
|
1588
1621
|
// V3 uses supportedUrls with media type patterns as keys
|
|
1589
1622
|
// Ollama supports images via URLs, files, and base64
|
|
@@ -1862,7 +1895,10 @@ var OllamaChatLanguageModel = class {
|
|
|
1862
1895
|
});
|
|
1863
1896
|
}
|
|
1864
1897
|
}
|
|
1865
|
-
const finishReason =
|
|
1898
|
+
const finishReason = mapOllamaFinishReason(
|
|
1899
|
+
response.done_reason,
|
|
1900
|
+
parsedToolCalls.length > 0
|
|
1901
|
+
);
|
|
1866
1902
|
return {
|
|
1867
1903
|
content,
|
|
1868
1904
|
finishReason,
|
|
@@ -2455,7 +2491,10 @@ var OllamaChatLanguageModel = class {
|
|
|
2455
2491
|
chunk.prompt_eval_count ?? void 0,
|
|
2456
2492
|
chunk.eval_count ?? void 0
|
|
2457
2493
|
);
|
|
2458
|
-
finishReason =
|
|
2494
|
+
finishReason = mapOllamaFinishReason(
|
|
2495
|
+
chunk.done_reason,
|
|
2496
|
+
hasToolCalls
|
|
2497
|
+
);
|
|
2459
2498
|
controller.enqueue({
|
|
2460
2499
|
type: "finish",
|
|
2461
2500
|
finishReason,
|
|
@@ -2558,8 +2597,8 @@ var OllamaChatLanguageModel = class {
|
|
|
2558
2597
|
// src/models/embedding-model.ts
|
|
2559
2598
|
var OllamaEmbeddingModel = class {
|
|
2560
2599
|
constructor(modelId, settings, config2) {
|
|
2561
|
-
this
|
|
2562
|
-
this
|
|
2600
|
+
__publicField(this, "settings", settings);
|
|
2601
|
+
__publicField(this, "config", config2);
|
|
2563
2602
|
__publicField(this, "specificationVersion", "v3");
|
|
2564
2603
|
__publicField(this, "modelId");
|
|
2565
2604
|
__publicField(this, "maxEmbeddingsPerCall", 2048);
|
|
@@ -3221,7 +3260,7 @@ function $constructor(name, initializer3, params) {
|
|
|
3221
3260
|
Object.defineProperty(_, "name", { value: name });
|
|
3222
3261
|
return _;
|
|
3223
3262
|
}
|
|
3224
|
-
var $brand = Symbol("zod_brand");
|
|
3263
|
+
var $brand = /* @__PURE__ */ Symbol("zod_brand");
|
|
3225
3264
|
var $ZodAsyncError = class extends Error {
|
|
3226
3265
|
constructor() {
|
|
3227
3266
|
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
@@ -12964,8 +13003,8 @@ function yo_default() {
|
|
|
12964
13003
|
|
|
12965
13004
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
|
|
12966
13005
|
var _a2;
|
|
12967
|
-
var $output = Symbol("ZodOutput");
|
|
12968
|
-
var $input = Symbol("ZodInput");
|
|
13006
|
+
var $output = /* @__PURE__ */ Symbol("ZodOutput");
|
|
13007
|
+
var $input = /* @__PURE__ */ Symbol("ZodInput");
|
|
12969
13008
|
var $ZodRegistry = class {
|
|
12970
13009
|
constructor() {
|
|
12971
13010
|
this._map = /* @__PURE__ */ new WeakMap();
|
|
@@ -17407,7 +17446,7 @@ var ollamaImageProviderOptionsSchema = external_exports.object({
|
|
|
17407
17446
|
});
|
|
17408
17447
|
var OllamaImageModel = class {
|
|
17409
17448
|
constructor(modelId, config2) {
|
|
17410
|
-
this
|
|
17449
|
+
__publicField(this, "config", config2);
|
|
17411
17450
|
__publicField(this, "specificationVersion", "v3");
|
|
17412
17451
|
__publicField(this, "provider");
|
|
17413
17452
|
__publicField(this, "modelId");
|