ai 7.0.60 → 7.0.62
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 +16 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +3 -3
- package/docs/03-ai-sdk-core/38-video-generation.mdx +16 -15
- package/docs/04-ai-sdk-ui/05-completion.mdx +21 -0
- package/docs/07-reference/02-ai-sdk-ui/02-use-completion.mdx +15 -2
- package/package.json +3 -3
- package/src/ui/chat.ts +20 -4
- package/src/ui/use-completion.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.62
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e0bcf52: feat(ui): add typed custom bodies to Completion APIs
|
|
8
|
+
|
|
9
|
+
## 7.0.61
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 326054b: Prevent `resumeStream` from copying the previous assistant message into the resumed response.
|
|
14
|
+
- 975bb28: Cancel messages that are still being prepared when a chat is stopped.
|
|
15
|
+
- Updated dependencies [7fbfc6d]
|
|
16
|
+
- @ai-sdk/provider-utils@5.0.27
|
|
17
|
+
- @ai-sdk/gateway@4.0.49
|
|
18
|
+
|
|
3
19
|
## 7.0.60
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -5491,6 +5491,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
5491
5491
|
private onFinish?;
|
|
5492
5492
|
private onData?;
|
|
5493
5493
|
private sendAutomaticallyWhen?;
|
|
5494
|
+
private pendingMessagePreparations;
|
|
5494
5495
|
private activeResponse;
|
|
5495
5496
|
private activeResumeRequest;
|
|
5496
5497
|
private jobExecutor;
|
|
@@ -5760,7 +5761,7 @@ declare class TextStreamChatTransport<UI_MESSAGE extends UIMessage> extends Http
|
|
|
5760
5761
|
protected processResponseStream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): ReadableStream<UIMessageChunk>;
|
|
5761
5762
|
}
|
|
5762
5763
|
|
|
5763
|
-
type CompletionRequestOptions = {
|
|
5764
|
+
type CompletionRequestOptions<BODY extends object = object> = {
|
|
5764
5765
|
/**
|
|
5765
5766
|
* An optional object of headers to be passed to the API endpoint.
|
|
5766
5767
|
*/
|
|
@@ -5768,9 +5769,9 @@ type CompletionRequestOptions = {
|
|
|
5768
5769
|
/**
|
|
5769
5770
|
* An optional object to be passed to the API endpoint.
|
|
5770
5771
|
*/
|
|
5771
|
-
body?:
|
|
5772
|
+
body?: BODY;
|
|
5772
5773
|
};
|
|
5773
|
-
type UseCompletionOptions = {
|
|
5774
|
+
type UseCompletionOptions<BODY extends object = object> = {
|
|
5774
5775
|
/**
|
|
5775
5776
|
* The API endpoint that accepts a `{ prompt: string }` object and returns
|
|
5776
5777
|
* a stream of tokens of the AI completion response. Defaults to `/api/completion`.
|
|
@@ -5820,7 +5821,7 @@ type UseCompletionOptions = {
|
|
|
5820
5821
|
* })
|
|
5821
5822
|
* ```
|
|
5822
5823
|
*/
|
|
5823
|
-
body?:
|
|
5824
|
+
body?: BODY;
|
|
5824
5825
|
/**
|
|
5825
5826
|
* Streaming protocol that is used. Defaults to `data`.
|
|
5826
5827
|
*/
|
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.62" : "0.0.0-test";
|
|
1147
1147
|
|
|
1148
1148
|
// src/util/download/download.ts
|
|
1149
1149
|
var download = async ({
|
|
@@ -17579,6 +17579,7 @@ var AbstractChat = class {
|
|
|
17579
17579
|
onData,
|
|
17580
17580
|
sendAutomaticallyWhen
|
|
17581
17581
|
}) {
|
|
17582
|
+
this.pendingMessagePreparations = /* @__PURE__ */ new Set();
|
|
17582
17583
|
this.activeResponse = void 0;
|
|
17583
17584
|
this.activeResumeRequest = void 0;
|
|
17584
17585
|
this.jobExecutor = new SerialJobExecutor();
|
|
@@ -17600,7 +17601,17 @@ var AbstractChat = class {
|
|
|
17600
17601
|
}
|
|
17601
17602
|
let uiMessage;
|
|
17602
17603
|
if ("text" in message || "files" in message) {
|
|
17603
|
-
const
|
|
17604
|
+
const abortController = new AbortController();
|
|
17605
|
+
this.pendingMessagePreparations.add(abortController);
|
|
17606
|
+
let fileParts;
|
|
17607
|
+
try {
|
|
17608
|
+
fileParts = Array.isArray(message.files) ? message.files : await convertFileListToFileUIParts(message.files);
|
|
17609
|
+
} finally {
|
|
17610
|
+
this.pendingMessagePreparations.delete(abortController);
|
|
17611
|
+
}
|
|
17612
|
+
if (abortController.signal.aborted) {
|
|
17613
|
+
return;
|
|
17614
|
+
}
|
|
17604
17615
|
uiMessage = {
|
|
17605
17616
|
parts: [
|
|
17606
17617
|
...fileParts,
|
|
@@ -17751,6 +17762,9 @@ var AbstractChat = class {
|
|
|
17751
17762
|
*/
|
|
17752
17763
|
this.stop = async () => {
|
|
17753
17764
|
var _a23, _b;
|
|
17765
|
+
for (const controller of this.pendingMessagePreparations) {
|
|
17766
|
+
controller.abort();
|
|
17767
|
+
}
|
|
17754
17768
|
(_a23 = this.activeResumeRequest) == null ? void 0 : _a23.abortController.abort();
|
|
17755
17769
|
(_b = this.activeResponse) == null ? void 0 : _b.abortController.abort();
|
|
17756
17770
|
};
|
|
@@ -17882,7 +17896,7 @@ var AbstractChat = class {
|
|
|
17882
17896
|
try {
|
|
17883
17897
|
const response = {
|
|
17884
17898
|
state: createStreamingUIMessageState({
|
|
17885
|
-
lastMessage: trigger === "regenerate-message" ? void 0 : this.state.snapshot(lastMessage),
|
|
17899
|
+
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? void 0 : this.state.snapshot(lastMessage),
|
|
17886
17900
|
messageId: this.generateId()
|
|
17887
17901
|
}),
|
|
17888
17902
|
abortController
|