@ai-sdk/svelte
Advanced tools
Comparing version 0.0.8 to 0.0.9
# @ai-sdk/svelte | ||
## 0.0.9 | ||
### Patch Changes | ||
- 827ef450: feat (ai/ui): improve error handling in useAssistant | ||
## 0.0.8 | ||
@@ -4,0 +10,0 @@ |
@@ -416,3 +416,3 @@ "use strict"; | ||
async function append(message, requestOptions) { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e; | ||
status.set("in_progress"); | ||
@@ -426,3 +426,3 @@ abortController = new AbortController(); | ||
try { | ||
const result = await fetch(api, { | ||
const response = await fetch(api, { | ||
method: "POST", | ||
@@ -441,7 +441,12 @@ credentials, | ||
}); | ||
if (result.body == null) { | ||
if (!response.ok) { | ||
throw new Error( | ||
(_c = await response.text()) != null ? _c : "Failed to fetch the assistant response." | ||
); | ||
} | ||
if (response.body == null) { | ||
throw new Error("The response body is empty."); | ||
} | ||
for await (const { type, value } of (0, import_ui_utils3.readDataStream)( | ||
result.body.getReader() | ||
response.body.getReader() | ||
)) { | ||
@@ -475,3 +480,3 @@ switch (type) { | ||
{ | ||
id: (_c = value.id) != null ? _c : (0, import_ui_utils3.generateId)(), | ||
id: (_d = value.id) != null ? _d : (0, import_ui_utils3.generateId)(), | ||
role: "data", | ||
@@ -503,3 +508,3 @@ content: "", | ||
} catch (err) { | ||
if ((0, import_provider_utils.isAbortError)(error) && ((_d = abortController == null ? void 0 : abortController.signal) == null ? void 0 : _d.aborted)) { | ||
if ((0, import_provider_utils.isAbortError)(error) && ((_e = abortController == null ? void 0 : abortController.signal) == null ? void 0 : _e.aborted)) { | ||
abortController = null; | ||
@@ -506,0 +511,0 @@ return; |
{ | ||
"name": "@ai-sdk/svelte", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -115,3 +115,3 @@ import { isAbortError } from '@ai-sdk/provider-utils'; | ||
try { | ||
const result = await fetch(api, { | ||
const response = await fetch(api, { | ||
method: 'POST', | ||
@@ -132,3 +132,9 @@ credentials, | ||
if (result.body == null) { | ||
if (!response.ok) { | ||
throw new Error( | ||
(await response.text()) ?? 'Failed to fetch the assistant response.', | ||
); | ||
} | ||
if (response.body == null) { | ||
throw new Error('The response body is empty.'); | ||
@@ -139,3 +145,3 @@ } | ||
for await (const { type, value } of readDataStream( | ||
result.body.getReader(), | ||
response.body.getReader(), | ||
)) { | ||
@@ -142,0 +148,0 @@ switch (type) { |
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
131016
1956