ai 4.0.32 → 4.0.34
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 +17 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 4.0.34
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 2495973: feat (ai/core): use openai compatible mode for json schema conversion
|
8
|
+
- 2495973: fix (ai/core): duplicate instead of using reference in json schema
|
9
|
+
- Updated dependencies [2495973]
|
10
|
+
- Updated dependencies [2495973]
|
11
|
+
- @ai-sdk/ui-utils@1.0.9
|
12
|
+
- @ai-sdk/react@1.0.10
|
13
|
+
|
14
|
+
## 4.0.33
|
15
|
+
|
16
|
+
### Patch Changes
|
17
|
+
|
18
|
+
- 5510ee7: feat (ai/core): add stopStream option to streamText transforms
|
19
|
+
|
3
20
|
## 4.0.32
|
4
21
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -2134,9 +2134,13 @@ Enable streaming of tool call deltas as they are generated. Disabled by default.
|
|
2134
2134
|
experimental_toolCallStreaming?: boolean;
|
2135
2135
|
/**
|
2136
2136
|
Optional transformation that is applied to the stream.
|
2137
|
+
|
2138
|
+
@param stopStream - A function that stops the source stream.
|
2139
|
+
@param tools - The tools that are accessible to and can be called by the model. The model needs to support calling tools.
|
2137
2140
|
*/
|
2138
2141
|
experimental_transform?: (options: {
|
2139
2142
|
tools: TOOLS;
|
2143
|
+
stopStream: () => void;
|
2140
2144
|
}) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
|
2141
2145
|
/**
|
2142
2146
|
Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
package/dist/index.d.ts
CHANGED
@@ -2134,9 +2134,13 @@ Enable streaming of tool call deltas as they are generated. Disabled by default.
|
|
2134
2134
|
experimental_toolCallStreaming?: boolean;
|
2135
2135
|
/**
|
2136
2136
|
Optional transformation that is applied to the stream.
|
2137
|
+
|
2138
|
+
@param stopStream - A function that stops the source stream.
|
2139
|
+
@param tools - The tools that are accessible to and can be called by the model. The model needs to support calling tools.
|
2137
2140
|
*/
|
2138
2141
|
experimental_transform?: (options: {
|
2139
2142
|
tools: TOOLS;
|
2143
|
+
stopStream: () => void;
|
2140
2144
|
}) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
|
2141
2145
|
/**
|
2142
2146
|
Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
|
package/dist/index.js
CHANGED
@@ -1961,7 +1961,7 @@ var arrayOutputStrategy = (schema) => {
|
|
1961
1961
|
// be able to generate an array directly:
|
1962
1962
|
// possible future optimization: use arrays directly when model supports grammar-guided generation
|
1963
1963
|
jsonSchema: {
|
1964
|
-
$schema: "
|
1964
|
+
$schema: "https://json-schema.org/draft/2019-09/schema#",
|
1965
1965
|
type: "object",
|
1966
1966
|
properties: {
|
1967
1967
|
elements: { type: "array", items: itemSchema }
|
@@ -2073,7 +2073,7 @@ var enumOutputStrategy = (enumValues) => {
|
|
2073
2073
|
// be able to generate an enum value directly:
|
2074
2074
|
// possible future optimization: use enums directly when model supports top-level enums
|
2075
2075
|
jsonSchema: {
|
2076
|
-
$schema: "
|
2076
|
+
$schema: "https://json-schema.org/draft/2019-09/schema#",
|
2077
2077
|
type: "object",
|
2078
2078
|
properties: {
|
2079
2079
|
result: { type: "string", enum: enumValues }
|
@@ -2765,12 +2765,27 @@ function createStitchableStream() {
|
|
2765
2765
|
innerStreamReaders.push(innerStream.getReader());
|
2766
2766
|
waitForNewStream.resolve();
|
2767
2767
|
},
|
2768
|
+
/**
|
2769
|
+
* Gracefully close the outer stream. This will let the inner streams
|
2770
|
+
* finish processing and then close the outer stream.
|
2771
|
+
*/
|
2768
2772
|
close: () => {
|
2769
2773
|
isClosed = true;
|
2770
2774
|
waitForNewStream.resolve();
|
2771
2775
|
if (innerStreamReaders.length === 0) {
|
2772
2776
|
controller == null ? void 0 : controller.close();
|
2773
2777
|
}
|
2778
|
+
},
|
2779
|
+
/**
|
2780
|
+
* Immediately close the outer stream. This will cancel all inner streams
|
2781
|
+
* and close the outer stream.
|
2782
|
+
*/
|
2783
|
+
terminate: () => {
|
2784
|
+
isClosed = true;
|
2785
|
+
waitForNewStream.resolve();
|
2786
|
+
innerStreamReaders.forEach((reader) => reader.cancel());
|
2787
|
+
innerStreamReaders = [];
|
2788
|
+
controller == null ? void 0 : controller.close();
|
2774
2789
|
}
|
2775
2790
|
};
|
2776
2791
|
}
|
@@ -4455,7 +4470,7 @@ function streamText({
|
|
4455
4470
|
tools,
|
4456
4471
|
toolChoice,
|
4457
4472
|
toolCallStreaming,
|
4458
|
-
transform
|
4473
|
+
transform,
|
4459
4474
|
activeTools,
|
4460
4475
|
repairToolCall,
|
4461
4476
|
maxSteps,
|
@@ -4729,7 +4744,14 @@ var DefaultStreamTextResult = class {
|
|
4729
4744
|
this.closeStream = stitchableStream.close;
|
4730
4745
|
let stream = stitchableStream.stream;
|
4731
4746
|
if (transform) {
|
4732
|
-
stream = stream.pipeThrough(
|
4747
|
+
stream = stream.pipeThrough(
|
4748
|
+
transform({
|
4749
|
+
tools,
|
4750
|
+
stopStream() {
|
4751
|
+
stitchableStream.terminate();
|
4752
|
+
}
|
4753
|
+
})
|
4754
|
+
);
|
4733
4755
|
}
|
4734
4756
|
this.baseStream = stream.pipeThrough(createOutputTransformStream(output)).pipeThrough(eventProcessor);
|
4735
4757
|
const { maxRetries, retry } = prepareRetries({
|