@ai-sdk/svelte
Advanced tools
Comparing version 0.0.15 to 0.0.16
# @ai-sdk/svelte | ||
## 0.0.16 | ||
### Patch Changes | ||
- a6cb2c8b: feat (ai/ui): add keepLastMessageOnError option to useChat | ||
- Updated dependencies [a6cb2c8b] | ||
- @ai-sdk/ui-utils@0.0.13 | ||
## 0.0.15 | ||
@@ -4,0 +12,0 @@ |
@@ -45,3 +45,3 @@ import { Message, CreateMessage, ChatRequestOptions, JSONValue, UseChatOptions, RequestOptions, UseCompletionOptions, AssistantStatus, UseAssistantOptions } from '@ai-sdk/ui-utils'; | ||
}; | ||
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, streamMode, onResponse, onFinish, onError, credentials, headers, body, generateId, fetch, }?: UseChatOptions): UseChatHelpers; | ||
declare function useChat({ api, id, initialMessages, initialInput, sendExtraMessageFields, experimental_onFunctionCall, experimental_onToolCall, streamMode, onResponse, onFinish, onError, credentials, headers, body, generateId, fetch, keepLastMessageOnError, }?: UseChatOptions): UseChatHelpers; | ||
@@ -48,0 +48,0 @@ type UseCompletionHelpers = { |
@@ -33,3 +33,3 @@ "use strict"; | ||
var import_store = require("svelte/store"); | ||
var getStreamedResponse = async (api, chatRequest, mutate, mutateStreamData, existingData, extraMetadata, previousMessages, abortControllerRef, generateId2, streamMode, onFinish, onResponse, sendExtraMessageFields, fetch2) => { | ||
var getStreamedResponse = async (api, chatRequest, mutate, mutateStreamData, existingData, extraMetadata, previousMessages, abortControllerRef, generateId2, streamMode, onFinish, onResponse, sendExtraMessageFields, fetch2, keepLastMessageOnError) => { | ||
mutate(chatRequest.messages); | ||
@@ -86,3 +86,5 @@ const constructedMessagesPayload = sendExtraMessageFields ? chatRequest.messages : chatRequest.messages.map( | ||
restoreMessagesOnFailure() { | ||
mutate(previousMessages); | ||
if (!keepLastMessageOnError) { | ||
mutate(previousMessages); | ||
} | ||
}, | ||
@@ -119,3 +121,4 @@ onResponse, | ||
generateId: generateId2 = import_ui_utils.generateId, | ||
fetch: fetch2 | ||
fetch: fetch2, | ||
keepLastMessageOnError = false | ||
} = {}) { | ||
@@ -169,3 +172,4 @@ const chatId = id || `chat-${uniqueId++}`; | ||
sendExtraMessageFields, | ||
fetch2 | ||
fetch2, | ||
keepLastMessageOnError | ||
), | ||
@@ -172,0 +176,0 @@ experimental_onFunctionCall, |
{ | ||
"name": "@ai-sdk/svelte", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"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", | ||
"sswr": "2.1.0" | ||
@@ -22,0 +22,0 @@ }, |
@@ -86,2 +86,3 @@ import type { | ||
fetch: FetchFunction | undefined, | ||
keepLastMessageOnError: boolean | undefined, | ||
) => { | ||
@@ -145,3 +146,5 @@ // Do an optimistic update to the chat state to show the updated messages | ||
restoreMessagesOnFailure() { | ||
mutate(previousMessages); | ||
if (!keepLastMessageOnError) { | ||
mutate(previousMessages); | ||
} | ||
}, | ||
@@ -181,2 +184,3 @@ onResponse, | ||
fetch, | ||
keepLastMessageOnError = false, | ||
}: UseChatOptions = {}): UseChatHelpers { | ||
@@ -249,2 +253,3 @@ // Generate a unique id for the chat if not provided. | ||
fetch, | ||
keepLastMessageOnError, | ||
), | ||
@@ -251,0 +256,0 @@ experimental_onFunctionCall, |
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
139277
2045
+ 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