@ai-sdk/vue
Advanced tools
Comparing version 0.0.20 to 0.0.21
# @ai-sdk/vue | ||
## 0.0.21 | ||
### Patch Changes | ||
- f63829fe: feat (ai/ui): add allowEmptySubmit flag to handleSubmit | ||
- 4b2c09d9: feat (ai/ui): add mutator function support to useChat / setMessages | ||
- Updated dependencies [f63829fe] | ||
- @ai-sdk/ui-utils@0.0.17 | ||
## 0.0.20 | ||
@@ -4,0 +13,0 @@ |
@@ -30,3 +30,3 @@ import { Message, CreateMessage, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, AssistantStatus, UseAssistantOptions } from '@ai-sdk/ui-utils'; | ||
*/ | ||
setMessages: (messages: Message[]) => void; | ||
setMessages: (messages: Message[] | ((messages: Message[]) => Message[])) => void; | ||
/** The current value of the input */ | ||
@@ -33,0 +33,0 @@ input: Ref<string>; |
@@ -183,10 +183,5 @@ "use strict"; | ||
const append = async (message, options) => { | ||
var _a2, _b2, _c, _d; | ||
if (!message.id) { | ||
message.id = generateId2(); | ||
} | ||
const requestOptions = { | ||
headers: (_b2 = options == null ? void 0 : options.headers) != null ? _b2 : (_a2 = options == null ? void 0 : options.options) == null ? void 0 : _a2.headers, | ||
body: (_d = options == null ? void 0 : options.body) != null ? _d : (_c = options == null ? void 0 : options.options) == null ? void 0 : _c.body | ||
}; | ||
return triggerRequest(messages.value.concat(message), options); | ||
@@ -210,4 +205,7 @@ }; | ||
}; | ||
const setMessages = (messages2) => { | ||
mutate(messages2); | ||
const setMessages = (messagesArg) => { | ||
if (typeof messagesArg === "function") { | ||
messagesArg = messagesArg(messages.value); | ||
} | ||
mutate(messagesArg); | ||
}; | ||
@@ -219,4 +217,6 @@ const input = (0, import_vue.ref)(initialInput); | ||
const inputValue = input.value; | ||
if (!inputValue && !options.allowEmptySubmit) | ||
return; | ||
triggerRequest( | ||
inputValue ? messages.value.concat({ | ||
!inputValue && options.allowEmptySubmit ? messages.value : messages.value.concat({ | ||
id: generateId2(), | ||
@@ -226,3 +226,3 @@ createdAt: /* @__PURE__ */ new Date(), | ||
role: "user" | ||
}) : messages.value, | ||
}), | ||
options | ||
@@ -229,0 +229,0 @@ ); |
{ | ||
"name": "@ai-sdk/vue", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"license": "Apache-2.0", | ||
@@ -19,3 +19,3 @@ "sideEffects": false, | ||
"@ai-sdk/provider-utils": "0.0.14", | ||
"@ai-sdk/ui-utils": "0.0.16", | ||
"@ai-sdk/ui-utils": "0.0.17", | ||
"swrv": "1.0.4" | ||
@@ -22,0 +22,0 @@ }, |
@@ -50,3 +50,5 @@ import type { | ||
*/ | ||
setMessages: (messages: Message[]) => void; | ||
setMessages: ( | ||
messages: Message[] | ((messages: Message[]) => Message[]), | ||
) => void; | ||
/** The current value of the input */ | ||
@@ -242,7 +244,2 @@ input: Ref<string>; | ||
const requestOptions = { | ||
headers: options?.headers ?? options?.options?.headers, | ||
body: options?.body ?? options?.options?.body, | ||
}; | ||
return triggerRequest(messages.value.concat(message as Message), options); | ||
@@ -269,4 +266,10 @@ }; | ||
const setMessages = (messages: Message[]) => { | ||
mutate(messages); | ||
const setMessages = ( | ||
messagesArg: Message[] | ((messages: Message[]) => Message[]), | ||
) => { | ||
if (typeof messagesArg === 'function') { | ||
messagesArg = messagesArg(messages.value); | ||
} | ||
mutate(messagesArg); | ||
}; | ||
@@ -284,5 +287,8 @@ | ||
if (!inputValue && !options.allowEmptySubmit) return; | ||
triggerRequest( | ||
inputValue | ||
? messages.value.concat({ | ||
!inputValue && options.allowEmptySubmit | ||
? messages.value | ||
: messages.value.concat({ | ||
id: generateId(), | ||
@@ -292,4 +298,3 @@ createdAt: new Date(), | ||
role: 'user', | ||
}) | ||
: messages.value, | ||
}), | ||
options, | ||
@@ -296,0 +301,0 @@ ); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
157513
34
2406
+ Added@ai-sdk/ui-utils@0.0.17(transitive)
- Removed@ai-sdk/ui-utils@0.0.16(transitive)
Updated@ai-sdk/ui-utils@0.0.17