@ai-sdk/react
Advanced tools
Comparing version 0.0.20 to 0.0.21
# @ai-sdk/react | ||
## 0.0.21 | ||
### Patch Changes | ||
- a6cb2c8b: feat (ai/ui): add keepLastMessageOnError option to useChat | ||
- Updated dependencies [a6cb2c8b] | ||
- @ai-sdk/ui-utils@0.0.13 | ||
## 0.0.20 | ||
@@ -4,0 +12,0 @@ |
@@ -112,3 +112,3 @@ import { Message, CreateMessage, AssistantStatus, UseAssistantOptions, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, DeepPartial, FetchFunction } from '@ai-sdk/ui-utils'; | ||
}; | ||
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, onToolCall, experimental_prepareRequestBody, experimental_maxAutomaticRoundtrips, maxAutomaticRoundtrips, maxToolRoundtrips, streamMode, onResponse, onFinish, onError, credentials, headers, body, generateId, fetch, }?: UseChatOptions & { | ||
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, onToolCall, experimental_prepareRequestBody, experimental_maxAutomaticRoundtrips, maxAutomaticRoundtrips, maxToolRoundtrips, streamMode, onResponse, onFinish, onError, credentials, headers, body, generateId, fetch, keepLastMessageOnError, }?: UseChatOptions & { | ||
key?: string; | ||
@@ -115,0 +115,0 @@ /** |
@@ -218,3 +218,3 @@ "use strict"; | ||
var import_swr = __toESM(require("swr")); | ||
var getStreamedResponse = async (api, chatRequest, mutate, mutateStreamData, existingData, extraMetadataRef, messagesRef, abortControllerRef, generateId2, streamMode, onFinish, onResponse, onToolCall, sendExtraMessageFields, experimental_prepareRequestBody, fetch2) => { | ||
var getStreamedResponse = async (api, chatRequest, mutate, mutateStreamData, existingData, extraMetadataRef, messagesRef, abortControllerRef, generateId2, streamMode, onFinish, onResponse, onToolCall, sendExtraMessageFields, experimental_prepareRequestBody, fetch2, keepLastMessageOnError) => { | ||
var _a; | ||
@@ -279,3 +279,5 @@ const previousMessages = messagesRef.current; | ||
restoreMessagesOnFailure() { | ||
mutate(previousMessages, false); | ||
if (!keepLastMessageOnError) { | ||
mutate(previousMessages, false); | ||
} | ||
}, | ||
@@ -314,3 +316,4 @@ onResponse, | ||
generateId: generateId2 = import_ui_utils2.generateId, | ||
fetch: fetch2 | ||
fetch: fetch2, | ||
keepLastMessageOnError = false | ||
} = {}) { | ||
@@ -374,3 +377,4 @@ const hookId = (0, import_react2.useId)(); | ||
experimental_prepareRequestBody, | ||
fetch2 | ||
fetch2, | ||
keepLastMessageOnError | ||
), | ||
@@ -431,3 +435,4 @@ experimental_onFunctionCall, | ||
generateId2, | ||
fetch2 | ||
fetch2, | ||
keepLastMessageOnError | ||
] | ||
@@ -434,0 +439,0 @@ ); |
{ | ||
"name": "@ai-sdk/react", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"license": "Apache-2.0", | ||
@@ -19,3 +19,3 @@ "sideEffects": false, | ||
"@ai-sdk/provider-utils": "1.0.2", | ||
"@ai-sdk/ui-utils": "0.0.12", | ||
"@ai-sdk/ui-utils": "0.0.13", | ||
"swr": "2.2.0" | ||
@@ -22,0 +22,0 @@ }, |
@@ -99,5 +99,5 @@ import type { | ||
fetch: FetchFunction | undefined, | ||
keepLastMessageOnError: boolean, | ||
) => { | ||
// Do an optimistic update to the chat state to show the updated messages | ||
// immediately. | ||
// Do an optimistic update to the chat state to show the updated messages immediately: | ||
const previousMessages = messagesRef.current; | ||
@@ -165,3 +165,5 @@ mutate(chatRequest.messages, false); | ||
restoreMessagesOnFailure() { | ||
mutate(previousMessages, false); | ||
if (!keepLastMessageOnError) { | ||
mutate(previousMessages, false); | ||
} | ||
}, | ||
@@ -202,2 +204,3 @@ onResponse, | ||
fetch, | ||
keepLastMessageOnError = false, | ||
}: UseChatOptions & { | ||
@@ -347,2 +350,3 @@ key?: string; | ||
fetch, | ||
keepLastMessageOnError, | ||
), | ||
@@ -414,2 +418,3 @@ experimental_onFunctionCall, | ||
fetch, | ||
keepLastMessageOnError, | ||
], | ||
@@ -416,0 +421,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
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
252370
4178
+ Added@ai-sdk/ui-utils@0.0.13(transitive)
- Removed@ai-sdk/ui-utils@0.0.12(transitive)
Updated@ai-sdk/ui-utils@0.0.13