ai 7.0.63 → 7.0.65
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 +19 -0
- package/dist/index.js +44 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +0 -1
- package/package.json +2 -2
- package/src/generate-object/output-strategy.ts +11 -2
- package/src/generate-text/output.ts +12 -2
- package/src/ui/chat.ts +5 -7
- package/src/ui-message-stream/read-ui-message-stream.ts +30 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.65
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dc8caae: Avoid repeatedly cloning accumulated text in `readUIMessageStream` while
|
|
8
|
+
preserving independent snapshots for mutable nested values.
|
|
9
|
+
- 72ec74f: Preserve root-level JSON Schema definitions when wrapping array output schemas.
|
|
10
|
+
- c5b0515: Propagate errors thrown by the Chat `onFinish` callback to the initiating request.
|
|
11
|
+
- Updated dependencies [16650e9]
|
|
12
|
+
- @ai-sdk/gateway@4.0.52
|
|
13
|
+
|
|
14
|
+
## 7.0.64
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [ea75787]
|
|
19
|
+
- Updated dependencies [b20de9e]
|
|
20
|
+
- @ai-sdk/gateway@4.0.51
|
|
21
|
+
|
|
3
22
|
## 7.0.63
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1143,7 +1143,7 @@ import {
|
|
|
1143
1143
|
} from "@ai-sdk/provider-utils";
|
|
1144
1144
|
|
|
1145
1145
|
// src/version.ts
|
|
1146
|
-
var VERSION = true ? "7.0.
|
|
1146
|
+
var VERSION = true ? "7.0.65" : "0.0.0-test";
|
|
1147
1147
|
|
|
1148
1148
|
// src/util/download/download.ts
|
|
1149
1149
|
var download = async ({
|
|
@@ -3601,11 +3601,18 @@ var array2 = ({
|
|
|
3601
3601
|
name: "array",
|
|
3602
3602
|
// JSON schema that describes an array of elements:
|
|
3603
3603
|
responseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
3604
|
-
const {
|
|
3604
|
+
const {
|
|
3605
|
+
$schema: _$schema,
|
|
3606
|
+
definitions,
|
|
3607
|
+
$defs,
|
|
3608
|
+
...itemSchema
|
|
3609
|
+
} = jsonSchema2;
|
|
3605
3610
|
return {
|
|
3606
3611
|
type: "json",
|
|
3607
3612
|
schema: {
|
|
3608
3613
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
3614
|
+
...definitions != null && { definitions },
|
|
3615
|
+
...$defs != null && { $defs },
|
|
3609
3616
|
type: "object",
|
|
3610
3617
|
properties: {
|
|
3611
3618
|
elements: { type: "array", items: itemSchema }
|
|
@@ -10704,6 +10711,27 @@ function createUIMessageStream({
|
|
|
10704
10711
|
}
|
|
10705
10712
|
|
|
10706
10713
|
// src/ui-message-stream/read-ui-message-stream.ts
|
|
10714
|
+
function createUIMessageSnapshot(message) {
|
|
10715
|
+
const textByPartIndex = /* @__PURE__ */ new Map();
|
|
10716
|
+
const messageWithoutText = {
|
|
10717
|
+
...message,
|
|
10718
|
+
parts: message.parts.map((part, index) => {
|
|
10719
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
10720
|
+
textByPartIndex.set(index, part.text);
|
|
10721
|
+
return { ...part, text: "" };
|
|
10722
|
+
}
|
|
10723
|
+
return part;
|
|
10724
|
+
})
|
|
10725
|
+
};
|
|
10726
|
+
const snapshot = structuredClone(messageWithoutText);
|
|
10727
|
+
for (const [index, text2] of textByPartIndex) {
|
|
10728
|
+
const part = snapshot.parts[index];
|
|
10729
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
10730
|
+
part.text = text2;
|
|
10731
|
+
}
|
|
10732
|
+
}
|
|
10733
|
+
return snapshot;
|
|
10734
|
+
}
|
|
10707
10735
|
function readUIMessageStream({
|
|
10708
10736
|
message,
|
|
10709
10737
|
stream,
|
|
@@ -10736,7 +10764,7 @@ function readUIMessageStream({
|
|
|
10736
10764
|
return job({
|
|
10737
10765
|
state,
|
|
10738
10766
|
write: () => {
|
|
10739
|
-
controller == null ? void 0 : controller.enqueue(
|
|
10767
|
+
controller == null ? void 0 : controller.enqueue(createUIMessageSnapshot(state.message));
|
|
10740
10768
|
}
|
|
10741
10769
|
});
|
|
10742
10770
|
},
|
|
@@ -12561,9 +12589,16 @@ var arrayOutputStrategy = (schema) => {
|
|
|
12561
12589
|
// be able to generate an array directly:
|
|
12562
12590
|
// possible future optimization: use arrays directly when model supports grammar-guided generation
|
|
12563
12591
|
jsonSchema: async () => {
|
|
12564
|
-
const {
|
|
12592
|
+
const {
|
|
12593
|
+
$schema: _$schema,
|
|
12594
|
+
definitions,
|
|
12595
|
+
$defs,
|
|
12596
|
+
...itemSchema
|
|
12597
|
+
} = await schema.jsonSchema;
|
|
12565
12598
|
return {
|
|
12566
12599
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
12600
|
+
...definitions != null && { definitions },
|
|
12601
|
+
...$defs != null && { $defs },
|
|
12567
12602
|
type: "object",
|
|
12568
12603
|
properties: {
|
|
12569
12604
|
elements: { type: "array", items: itemSchema }
|
|
@@ -18007,13 +18042,12 @@ var AbstractChat = class {
|
|
|
18007
18042
|
finishReason: activeResponse.state.finishReason
|
|
18008
18043
|
});
|
|
18009
18044
|
}
|
|
18010
|
-
}
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18045
|
+
} finally {
|
|
18046
|
+
if (this.activeResponse === activeResponse) {
|
|
18047
|
+
this.activeResponse = void 0;
|
|
18048
|
+
}
|
|
18049
|
+
clearActiveResumeRequest();
|
|
18015
18050
|
}
|
|
18016
|
-
clearActiveResumeRequest();
|
|
18017
18051
|
}
|
|
18018
18052
|
if (!isError && await this.shouldSendAutomatically()) {
|
|
18019
18053
|
await this.makeRequest({
|