ai-sdk-ollama 4.6.0 → 4.6.2
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/dist/index.browser.cjs +36 -3
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +36 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +36 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/dist/models/chat-language-model.d.ts.map +1 -1
- package/dist/models/chat-stream.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 518ddf1: Harden the stream for custom `OllamaClient` adapters whose iterator ends cleanly without the final `done` chunk: close any open text or reasoning block, emit an `error` part and end the stream with a `finish` part (reason `error`). The default client already throws in that case, so its streams still error as before.
|
|
8
|
+
|
|
9
|
+
## 4.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- f472ffd: Abort the Ollama request when the stream returned by `doStream` is cancelled, so the server stops generating once the consumer stops reading.
|
|
14
|
+
- 1645fac: Fall back to the default embedding reranking batch size when a supplied value would round down to zero, preventing repeated empty embedding requests.
|
|
15
|
+
|
|
3
16
|
## 4.6.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/index.browser.cjs
CHANGED
|
@@ -1976,6 +1976,7 @@ function buildObjectGenerationResult(parameters) {
|
|
|
1976
1976
|
}
|
|
1977
1977
|
|
|
1978
1978
|
// src/models/chat-stream.ts
|
|
1979
|
+
var import_provider = require("@ai-sdk/provider");
|
|
1979
1980
|
function createChunkTransformer({
|
|
1980
1981
|
warnings,
|
|
1981
1982
|
includeRawChunks
|
|
@@ -1984,6 +1985,7 @@ function createChunkTransformer({
|
|
|
1984
1985
|
let textId;
|
|
1985
1986
|
let reasoningId;
|
|
1986
1987
|
let hasToolCalls = false;
|
|
1988
|
+
let finished = false;
|
|
1987
1989
|
function endReasoning(controller) {
|
|
1988
1990
|
if (reasoningId === void 0) {
|
|
1989
1991
|
return;
|
|
@@ -2048,6 +2050,7 @@ function createChunkTransformer({
|
|
|
2048
2050
|
emitReasoning(controller, thinking);
|
|
2049
2051
|
}
|
|
2050
2052
|
if (chunk.done) {
|
|
2053
|
+
finished = true;
|
|
2051
2054
|
endReasoning(controller);
|
|
2052
2055
|
if (hasContent) {
|
|
2053
2056
|
emitText(controller, content);
|
|
@@ -2066,6 +2069,33 @@ function createChunkTransformer({
|
|
|
2066
2069
|
if (hasContent) {
|
|
2067
2070
|
emitText(controller, content);
|
|
2068
2071
|
}
|
|
2072
|
+
},
|
|
2073
|
+
// Hardening for clients whose iterator ends cleanly without Ollama's
|
|
2074
|
+
// `done` chunk (a custom `OllamaClient` adapter). The default client throws
|
|
2075
|
+
// in that case, so the stream errors and this never runs. Close what is
|
|
2076
|
+
// open, report the early end as an error and still end the stream with a
|
|
2077
|
+
// finish part, so consumers do not wait on a part that never comes.
|
|
2078
|
+
flush(controller) {
|
|
2079
|
+
if (finished) {
|
|
2080
|
+
return;
|
|
2081
|
+
}
|
|
2082
|
+
if (!streamStarted) {
|
|
2083
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
2084
|
+
}
|
|
2085
|
+
endReasoning(controller);
|
|
2086
|
+
endText(controller);
|
|
2087
|
+
controller.enqueue({
|
|
2088
|
+
type: "error",
|
|
2089
|
+
error: new import_provider.InvalidResponseDataError({
|
|
2090
|
+
data: void 0,
|
|
2091
|
+
message: "Ollama stream ended without a done chunk."
|
|
2092
|
+
})
|
|
2093
|
+
});
|
|
2094
|
+
controller.enqueue({
|
|
2095
|
+
type: "finish",
|
|
2096
|
+
finishReason: { unified: "error", raw: void 0 },
|
|
2097
|
+
usage: aggregateUsage()
|
|
2098
|
+
});
|
|
2069
2099
|
}
|
|
2070
2100
|
});
|
|
2071
2101
|
}
|
|
@@ -2580,6 +2610,9 @@ var OllamaChatLanguageModel = class {
|
|
|
2580
2610
|
} catch (error62) {
|
|
2581
2611
|
controller.error(error62);
|
|
2582
2612
|
}
|
|
2613
|
+
},
|
|
2614
|
+
cancel() {
|
|
2615
|
+
stream.abort();
|
|
2583
2616
|
}
|
|
2584
2617
|
});
|
|
2585
2618
|
return {
|
|
@@ -22524,7 +22557,7 @@ var OllamaEmbeddingRerankingModel = class {
|
|
|
22524
22557
|
*/
|
|
22525
22558
|
get embeddingBatchSize() {
|
|
22526
22559
|
const { maxBatchSize } = this.settings;
|
|
22527
|
-
if (typeof maxBatchSize === "number" && Number.isFinite(maxBatchSize) && maxBatchSize
|
|
22560
|
+
if (typeof maxBatchSize === "number" && Number.isFinite(maxBatchSize) && maxBatchSize >= 1) {
|
|
22528
22561
|
return Math.floor(maxBatchSize);
|
|
22529
22562
|
}
|
|
22530
22563
|
return 16;
|
|
@@ -22808,7 +22841,7 @@ var OllamaSpeechModel = class {
|
|
|
22808
22841
|
};
|
|
22809
22842
|
|
|
22810
22843
|
// src/models/decision-model.ts
|
|
22811
|
-
var
|
|
22844
|
+
var import_provider2 = require("@ai-sdk/provider");
|
|
22812
22845
|
var isList = (input2) => Array.isArray(input2);
|
|
22813
22846
|
var isText = (input2) => typeof input2 === "string";
|
|
22814
22847
|
var toContent = (input2) => isList(input2) ? [...input2] : input2;
|
|
@@ -22823,7 +22856,7 @@ function toStateValue(part) {
|
|
|
22823
22856
|
return part.value;
|
|
22824
22857
|
}
|
|
22825
22858
|
case "file": {
|
|
22826
|
-
throw new
|
|
22859
|
+
throw new import_provider2.UnsupportedFunctionalityError({
|
|
22827
22860
|
functionality: "file parts in decision state"
|
|
22828
22861
|
});
|
|
22829
22862
|
}
|