@ai-sdk/vue 4.0.120 → 4.0.123
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 +33 -0
- package/dist/index.d.ts +113 -109
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +423 -523
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @ai-sdk/vue
|
|
2
2
|
|
|
3
|
+
## 4.0.123
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ede5b89: chore: migrate package builds from tsup to tsdown
|
|
8
|
+
- Updated dependencies [05cdac6]
|
|
9
|
+
- Updated dependencies [4514fc1]
|
|
10
|
+
- Updated dependencies [ede5b89]
|
|
11
|
+
- Updated dependencies [2a625cf]
|
|
12
|
+
- Updated dependencies [50a26d5]
|
|
13
|
+
- ai@7.0.123
|
|
14
|
+
- @ai-sdk/provider-utils@5.0.52
|
|
15
|
+
|
|
16
|
+
## 4.0.122
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [f3575f8]
|
|
21
|
+
- Updated dependencies [27ab8d4]
|
|
22
|
+
- ai@7.0.122
|
|
23
|
+
|
|
24
|
+
## 4.0.121
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [c5e90bb]
|
|
29
|
+
- Updated dependencies [c2511c1]
|
|
30
|
+
- Updated dependencies [868c475]
|
|
31
|
+
- Updated dependencies [119536f]
|
|
32
|
+
- Updated dependencies [9941f32]
|
|
33
|
+
- ai@7.0.121
|
|
34
|
+
- @ai-sdk/provider-utils@5.0.51
|
|
35
|
+
|
|
3
36
|
## 4.0.120
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,120 +1,122 @@
|
|
|
1
|
-
import { FetchFunction, FlexibleSchema
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
credentials?: RequestCredentials;
|
|
1
|
+
import { FetchFunction, FlexibleSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { AbstractChat, ChatInit, ChatStatus, CompletionRequestOptions, DeepPartial, FlexibleSchema as FlexibleSchema$1, InferSchema, UIMessage, UseCompletionOptions } from "ai";
|
|
3
|
+
import { ComputedRef, MaybeRefOrGetter, Ref, ShallowRef } from "vue";
|
|
4
|
+
//#region src/use-object.d.ts
|
|
5
|
+
export type UseObjectOptions<SCHEMA extends FlexibleSchema$1, RESULT> = {
|
|
6
|
+
/** API endpoint that streams JSON chunks matching the schema */
|
|
7
|
+
api: string;
|
|
8
|
+
/** Schema that defines the final object shape */
|
|
9
|
+
schema: SCHEMA;
|
|
10
|
+
/** Shared state key. If omitted a random one is generated */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** Initial partial value */
|
|
13
|
+
initialValue?: DeepPartial<RESULT>;
|
|
14
|
+
/** Optional custom fetch implementation */
|
|
15
|
+
fetch?: FetchFunction;
|
|
16
|
+
/** Called when stream ends */
|
|
17
|
+
onFinish?: (event: {
|
|
18
|
+
object: RESULT | undefined;
|
|
19
|
+
error: Error | undefined;
|
|
20
|
+
}) => Promise<void> | void;
|
|
21
|
+
/** Called on error */
|
|
22
|
+
onError?: (error: Error) => void;
|
|
23
|
+
/** Extra request headers */
|
|
24
|
+
headers?: Record<string, string> | Headers;
|
|
25
|
+
/** Request credentials mode. Defaults to 'same-origin' if omitted */
|
|
26
|
+
credentials?: RequestCredentials;
|
|
28
27
|
};
|
|
29
|
-
type UseObjectHelpers<RESULT, INPUT> = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
export type UseObjectHelpers<RESULT, INPUT> = {
|
|
29
|
+
/** POST the input and start streaming */
|
|
30
|
+
submit: (input: INPUT) => void;
|
|
31
|
+
/** Current partial object, updated as chunks arrive */
|
|
32
|
+
object: Ref<DeepPartial<RESULT> | undefined>;
|
|
33
|
+
/** Latest error if any */
|
|
34
|
+
error: Ref<Error | undefined>;
|
|
35
|
+
/** Loading flag for the in-flight request */
|
|
36
|
+
isLoading: Ref<boolean | undefined>;
|
|
37
|
+
/** Abort the current request. Keeps current partial object. */
|
|
38
|
+
stop: () => void;
|
|
39
|
+
/** Abort and clear all state */
|
|
40
|
+
clear: () => void;
|
|
42
41
|
};
|
|
43
|
-
declare function useObject<SCHEMA extends FlexibleSchema, RESULT = InferSchema<SCHEMA>, INPUT = any>({ api, id, schema, initialValue, fetch, onError, onFinish, headers, credentials
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
42
|
+
export declare function useObject<SCHEMA extends FlexibleSchema$1, RESULT = InferSchema<SCHEMA>, INPUT = any>({ api, id, schema, initialValue, fetch, onError, onFinish, headers, credentials }: UseObjectOptions<SCHEMA, RESULT>): UseObjectHelpers<RESULT, INPUT>;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/use-completion.d.ts
|
|
45
|
+
export type UseCompletionHelpers<BODY extends object = object> = {
|
|
46
|
+
/** The current completion result */
|
|
47
|
+
completion: Ref<string>;
|
|
48
|
+
/** The error object of the API request */
|
|
49
|
+
error: Ref<undefined | Error>;
|
|
50
|
+
/**
|
|
51
|
+
* Send a new prompt to the API endpoint and update the completion state.
|
|
52
|
+
*/
|
|
53
|
+
complete: (prompt: string, options?: CompletionRequestOptions<BODY>) => Promise<string | null | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* Abort the current API request but keep the generated tokens.
|
|
56
|
+
*/
|
|
57
|
+
stop: () => void;
|
|
58
|
+
/**
|
|
59
|
+
* Update the `completion` state locally.
|
|
60
|
+
*/
|
|
61
|
+
setCompletion: (completion: string) => void;
|
|
62
|
+
/** The current value of the input */
|
|
63
|
+
input: Ref<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Form submission handler to automatically reset input and append a user message
|
|
66
|
+
* @example
|
|
67
|
+
* ```jsx
|
|
68
|
+
* <form @submit="handleSubmit">
|
|
69
|
+
* <input @change="handleInputChange" v-model="input" />
|
|
70
|
+
* </form>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
handleSubmit: (event?: {
|
|
74
|
+
preventDefault?: () => void;
|
|
75
|
+
}) => void;
|
|
76
|
+
/** Whether the API request is in progress */
|
|
77
|
+
isLoading: Ref<boolean | undefined>;
|
|
78
78
|
};
|
|
79
|
-
declare function useCompletion<BODY extends object = object>({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, onFinish, onError, fetch
|
|
80
|
-
|
|
79
|
+
export declare function useCompletion<BODY extends object = object>({ api, id, initialCompletion, initialInput, credentials, headers, body, streamProtocol, onFinish, onError, fetch }?: UseCompletionOptions<NoInfer<BODY>>): UseCompletionHelpers<BODY>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/chat.vue.d.ts
|
|
81
82
|
/**
|
|
82
83
|
* @deprecated Use the {@link useChat} composable instead. It exposes reactive
|
|
83
84
|
* refs and automatically recreates the chat when its init object changes.
|
|
84
85
|
*/
|
|
85
|
-
declare class Chat<UI_MESSAGE extends UIMessage> extends AbstractChat<UI_MESSAGE> {
|
|
86
|
-
|
|
86
|
+
export declare class Chat<UI_MESSAGE extends UIMessage> extends AbstractChat<UI_MESSAGE> {
|
|
87
|
+
constructor({ messages, ...init }: ChatInit<UI_MESSAGE>);
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/use-chat.d.ts
|
|
89
91
|
/**
|
|
90
92
|
* Return type of the {@link useChat} composable, which includes the chat
|
|
91
93
|
* instance methods and reactive properties for messages, status, and error.
|
|
92
94
|
*/
|
|
93
95
|
interface UseChatHelpers<UI_MESSAGE extends UIMessage> extends Pick<AbstractChat<UI_MESSAGE>, 'sendMessage' | 'regenerate' | 'stop' | 'resumeStream' | 'addToolOutput' | 'addToolApprovalResponse' | 'clearError'> {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
/**
|
|
97
|
+
* The id of the chat.
|
|
98
|
+
*/
|
|
99
|
+
id: ComputedRef<string>;
|
|
100
|
+
/**
|
|
101
|
+
* The current error state of the chat, if any.
|
|
102
|
+
*/
|
|
103
|
+
error: ShallowRef<Error | undefined>;
|
|
104
|
+
/**
|
|
105
|
+
* The current status of the chat, which can be 'ready', 'generating', 'streaming', or 'error'.
|
|
106
|
+
*/
|
|
107
|
+
status: ShallowRef<ChatStatus>;
|
|
108
|
+
/**
|
|
109
|
+
* The list of messages in the chat, which can be updated by the chat instance methods or directly by setting this property.
|
|
110
|
+
*/
|
|
111
|
+
messages: ShallowRef<UI_MESSAGE[]>;
|
|
110
112
|
}
|
|
111
113
|
type UseChatOptions<UI_MESSAGE extends UIMessage> = ChatInit<UI_MESSAGE> & {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Custom throttle wait time in milliseconds for reactive message updates.
|
|
116
|
+
* Positive values enable throttling. Defaults to undefined, which disables
|
|
117
|
+
* throttling.
|
|
118
|
+
*/
|
|
119
|
+
throttle?: number;
|
|
118
120
|
};
|
|
119
121
|
/**
|
|
120
122
|
* Composable to access messages, status, and other chat properties and
|
|
@@ -132,19 +134,21 @@ type UseChatOptions<UI_MESSAGE extends UIMessage> = ChatInit<UI_MESSAGE> & {
|
|
|
132
134
|
*
|
|
133
135
|
* @see BaseChatInit
|
|
134
136
|
*/
|
|
135
|
-
declare function useChat<UI_MESSAGE extends UIMessage = UIMessage>(init?: MaybeRefOrGetter<UseChatOptions<UI_MESSAGE>>): UseChatHelpers<UI_MESSAGE>;
|
|
136
|
-
|
|
137
|
+
export declare function useChat<UI_MESSAGE extends UIMessage = UIMessage>(init?: MaybeRefOrGetter<UseChatOptions<UI_MESSAGE>>): UseChatHelpers<UI_MESSAGE>;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/index.d.ts
|
|
137
140
|
/**
|
|
138
141
|
* @deprecated Use `useObject` instead.
|
|
139
142
|
*/
|
|
140
|
-
declare const experimental_useObject: typeof useObject;
|
|
143
|
+
export declare const experimental_useObject: typeof useObject;
|
|
141
144
|
/**
|
|
142
145
|
* @deprecated Use `UseObjectOptions` instead.
|
|
143
146
|
*/
|
|
144
|
-
type Experimental_UseObjectOptions<SCHEMA extends FlexibleSchema
|
|
147
|
+
export type Experimental_UseObjectOptions<SCHEMA extends FlexibleSchema, RESULT> = UseObjectOptions<SCHEMA, RESULT>;
|
|
145
148
|
/**
|
|
146
149
|
* @deprecated Use `UseObjectHelpers` instead.
|
|
147
150
|
*/
|
|
148
|
-
type Experimental_UseObjectHelpers<RESULT, INPUT> = UseObjectHelpers<RESULT, INPUT>;
|
|
149
|
-
|
|
150
|
-
export {
|
|
151
|
+
export type Experimental_UseObjectHelpers<RESULT, INPUT> = UseObjectHelpers<RESULT, INPUT>;
|
|
152
|
+
//#endregion
|
|
153
|
+
export type { UseChatHelpers, UseChatOptions, UseCompletionOptions };
|
|
154
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["FlexibleSchema","BaseChatInit"],"sources":["../src/use-object.ts","../src/use-completion.ts","../src/chat.vue.ts","../src/use-chat.ts","../src/index.ts"],"mappings":";;;;YAmBY,iBAAiB,eAAeA,kBAAgB;;EAE1D;;EAGA,QAAQ;;EAGR;;EAGA,eAAe,YAAY;;EAG3B,QAAQ;;EAGR,YAAY;IACV,QAAQ;IACR,OAAO;QACH;;EAGN,WAAW,OAAO;;EAGlB,UAAU,yBAAyB;;EAGnC,cAAc;;YAGJ,iBAAiB,QAAQ;;EAEnC,SAAS,OAAO;;EAGhB,QAAQ,IAAI,YAAY;;EAGxB,OAAO,IAAI;;EAGX,WAAW;;EAGX;;EAGA;;wBASc,UACd,eAAeA,kBACf,SAAS,YAAY,SACrB,eAEA,KACA,IACA,QACA,cACA,OACA,SACA,UACA,SACA,eACC,iBAAiB,QAAQ,UAAU,iBAAiB,QAAQ;;;YCjFnD,qBAAqB;;EAE/B,YAAY;;EAEZ,OAAO,gBAAgB;;;;EAIvB,WACE,gBACA,UAAU,yBAAyB,UAChC;;;;EAIL;;;;EAIA,gBAAgB;;EAEhB,OAAO;;;;;;;;;;EAUP,eAAe;IAAU;;;EAEzB,WAAW;;wBASG,cAAc,gCAC5B,KACA,IACA,mBACA,cACA,aACA,SACA,MACA,gBACA,UACA,SACA,UACC,qBAAqB,QAAQ,SAAc,qBAAqB;;;;;;;qBCDtD,KACX,mBAAmB,mBACX,aAAa;EACT,cAAE,aAAa,QAAQ,SAAS;;;;;;;;UC8N7B,eAAe,mBAAmB,mBAAmB,KACpE,aAAa;;;;EAYb,IAAI;;;;EAKJ,OAAO,WAAW;;;;EAKlB,QAAQ,WAAW;;;;EAKnB,UAAU,WAAW;;KAGX,eAAe,mBAAmB,aAC5CC,SAAa;;;;;;EAMX;;;;;;;;;;;;;;;;;;wBAmBY,QAAQ,mBAAmB,YAAY,WACrD,OAAO,iBAAiB,eAAe,eACtC,eAAe;;;;;;qBCxUL,+BAAsB;;;;YAKvB,8BACV,eAAe,gBACf,UACE,iBAAiB,QAAQ;;;;YAKjB,8BAA8B,QAAQ,SAAS,iBACzD,QACA"}
|