@ai-sdk/vue 4.0.122 → 4.0.124

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @ai-sdk/vue
2
2
 
3
+ ## 4.0.124
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8c65988]
8
+ - Updated dependencies [527a163]
9
+ - ai@7.0.124
10
+ - @ai-sdk/provider-utils@5.0.53
11
+
12
+ ## 4.0.123
13
+
14
+ ### Patch Changes
15
+
16
+ - ede5b89: chore: migrate package builds from tsup to tsdown
17
+ - Updated dependencies [05cdac6]
18
+ - Updated dependencies [4514fc1]
19
+ - Updated dependencies [ede5b89]
20
+ - Updated dependencies [2a625cf]
21
+ - Updated dependencies [50a26d5]
22
+ - ai@7.0.123
23
+ - @ai-sdk/provider-utils@5.0.52
24
+
3
25
  ## 4.0.122
4
26
 
5
27
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,120 +1,122 @@
1
- import { FetchFunction, FlexibleSchema as FlexibleSchema$1 } from '@ai-sdk/provider-utils';
2
- import { FlexibleSchema, DeepPartial, InferSchema, CompletionRequestOptions, UseCompletionOptions, UIMessage, AbstractChat, ChatInit, ChatStatus } from 'ai';
3
- export { UseCompletionOptions } from 'ai';
4
- import { Ref, ComputedRef, ShallowRef, MaybeRefOrGetter } from 'vue';
5
-
6
- type UseObjectOptions<SCHEMA extends FlexibleSchema, RESULT> = {
7
- /** API endpoint that streams JSON chunks matching the schema */
8
- api: string;
9
- /** Schema that defines the final object shape */
10
- schema: SCHEMA;
11
- /** Shared state key. If omitted a random one is generated */
12
- id?: string;
13
- /** Initial partial value */
14
- initialValue?: DeepPartial<RESULT>;
15
- /** Optional custom fetch implementation */
16
- fetch?: FetchFunction;
17
- /** Called when stream ends */
18
- onFinish?: (event: {
19
- object: RESULT | undefined;
20
- error: Error | undefined;
21
- }) => Promise<void> | void;
22
- /** Called on error */
23
- onError?: (error: Error) => void;
24
- /** Extra request headers */
25
- headers?: Record<string, string> | Headers;
26
- /** Request credentials mode. Defaults to 'same-origin' if omitted */
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
- /** POST the input and start streaming */
31
- submit: (input: INPUT) => void;
32
- /** Current partial object, updated as chunks arrive */
33
- object: Ref<DeepPartial<RESULT> | undefined>;
34
- /** Latest error if any */
35
- error: Ref<Error | undefined>;
36
- /** Loading flag for the in-flight request */
37
- isLoading: Ref<boolean | undefined>;
38
- /** Abort the current request. Keeps current partial object. */
39
- stop: () => void;
40
- /** Abort and clear all state */
41
- clear: () => void;
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, }: UseObjectOptions<SCHEMA, RESULT>): UseObjectHelpers<RESULT, INPUT>;
44
-
45
- 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>;
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, }?: UseCompletionOptions<NoInfer<BODY>>): UseCompletionHelpers<BODY>;
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
- constructor({ messages, ...init }: ChatInit<UI_MESSAGE>);
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
- * The id of the chat.
96
- */
97
- id: ComputedRef<string>;
98
- /**
99
- * The current error state of the chat, if any.
100
- */
101
- error: ShallowRef<Error | undefined>;
102
- /**
103
- * The current status of the chat, which can be 'ready', 'generating', 'streaming', or 'error'.
104
- */
105
- status: ShallowRef<ChatStatus>;
106
- /**
107
- * The list of messages in the chat, which can be updated by the chat instance methods or directly by setting this property.
108
- */
109
- messages: ShallowRef<UI_MESSAGE[]>;
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
- * Custom throttle wait time in milliseconds for reactive message updates.
114
- * Positive values enable throttling. Defaults to undefined, which disables
115
- * throttling.
116
- */
117
- throttle?: number;
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$1, RESULT> = UseObjectOptions<SCHEMA, RESULT>;
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 { Chat, Experimental_UseObjectHelpers, Experimental_UseObjectOptions, UseChatHelpers, UseChatOptions, UseCompletionHelpers, UseObjectHelpers, UseObjectOptions, experimental_useObject, useChat, useCompletion, useObject };
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,W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