Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/react

Package Overview
Dependencies
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/react - npm Package Compare versions

Comparing version 0.0.25 to 0.0.26

9

CHANGELOG.md
# @ai-sdk/react
## 0.0.26
### 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.25

@@ -4,0 +13,0 @@

2

dist/index.d.ts

@@ -95,3 +95,3 @@ import { Message, CreateMessage, AssistantStatus, UseAssistantOptions, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, DeepPartial, FetchFunction } from '@ai-sdk/ui-utils';

*/
setMessages: (messages: Message[]) => void;
setMessages: (messages: Message[] | ((messages: Message[]) => Message[])) => void;
/** The current value of the input */

@@ -98,0 +98,0 @@ input: string;

@@ -514,2 +514,5 @@ "use strict";

(messages2) => {
if (typeof messages2 === "function") {
messages2 = messages2(messagesRef.current);
}
mutate(messages2, false);

@@ -524,2 +527,5 @@ messagesRef.current = messages2;

var _a, _b, _c, _d, _e;
(_a = event == null ? void 0 : event.preventDefault) == null ? void 0 : _a.call(event);
if (!input && !options.allowEmptySubmit)
return;
if (metadata) {

@@ -531,3 +537,2 @@ extraMetadataRef.current = {

}
(_a = event == null ? void 0 : event.preventDefault) == null ? void 0 : _a.call(event);
const attachmentsForRequest = [];

@@ -571,10 +576,11 @@ const attachmentsFromOptions = options.experimental_attachments;

};
const messages2 = !input && options.allowEmptySubmit ? messagesRef.current : messagesRef.current.concat({
id: generateId2(),
createdAt: /* @__PURE__ */ new Date(),
role: "user",
content: input,
experimental_attachments: attachmentsForRequest.length > 0 ? attachmentsForRequest : void 0
});
const chatRequest = {
messages: input ? messagesRef.current.concat({
id: generateId2(),
createdAt: /* @__PURE__ */ new Date(),
role: "user",
content: input,
experimental_attachments: attachmentsForRequest.length > 0 ? attachmentsForRequest : void 0
}) : messagesRef.current,
messages: messages2,
options: requestOptions,

@@ -581,0 +587,0 @@ headers: requestOptions.headers,

{
"name": "@ai-sdk/react",
"version": "0.0.25",
"version": "0.0.26",
"license": "Apache-2.0",

@@ -19,3 +19,3 @@ "sideEffects": false,

"@ai-sdk/provider-utils": "1.0.2",
"@ai-sdk/ui-utils": "0.0.16",
"@ai-sdk/ui-utils": "0.0.17",
"swr": "2.2.5"

@@ -22,0 +22,0 @@ },

@@ -54,3 +54,5 @@ import type {

*/
setMessages: (messages: Message[]) => void;
setMessages: (
messages: Message[] | ((messages: Message[]) => Message[]),
) => void;
/** The current value of the input */

@@ -511,3 +513,7 @@ input: string;

const setMessages = useCallback(
(messages: Message[]) => {
(messages: Message[] | ((messages: Message[]) => Message[])) => {
if (typeof messages === 'function') {
messages = messages(messagesRef.current);
}
mutate(messages, false);

@@ -528,2 +534,6 @@ messagesRef.current = messages;

) => {
event?.preventDefault?.();
if (!input && !options.allowEmptySubmit) return;
if (metadata) {

@@ -536,4 +546,2 @@ extraMetadataRef.current = {

event?.preventDefault?.();
const attachmentsForRequest: Attachment[] = [];

@@ -582,5 +590,6 @@ const attachmentsFromOptions = options.experimental_attachments;

const chatRequest: ChatRequest = {
messages: input
? messagesRef.current.concat({
const messages =
!input && options.allowEmptySubmit
? messagesRef.current
: messagesRef.current.concat({
id: generateId(),

@@ -594,4 +603,6 @@ createdAt: new Date(),

: undefined,
})
: messagesRef.current,
});
const chatRequest: ChatRequest = {
messages,
options: requestOptions,

@@ -598,0 +609,0 @@ headers: requestOptions.headers,

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc