-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pages about troubleshooting sdk errors #2806
base: main
Are you sure you want to change the base?
Conversation
@@ -1,10 +1,73 @@ | |||
--- | |||
title: AI_InvalidDataContentError | |||
description: How to fix AI_InvalidDataContentError | |||
title: InvalidDataContentError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had AI_
prefix on purpose for SEO
## Usage | ||
|
||
```ts | ||
import { InvalidDataContentError } from '@ai-sdk/core'; | ||
|
||
try { | ||
// Code that might throw an InvalidDataContentError | ||
} catch (error) { | ||
if (InvalidDataContentError.isInstance(error)) { | ||
console.log('An invalid data content error occurred:', error.message); | ||
// Handle the error appropriately | ||
} else { | ||
// Handle other types of errors | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe some additional context is helpful
@@ -0,0 +1,60 @@ | |||
--- | |||
title: APICallError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI_
description: Error thrown during a failed API call | ||
--- | ||
|
||
# APICallError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI_
The `APICallError` occurs when there's an issue during an API call made by the SDK. This can happen in various scenarios, such as: | ||
|
||
1. Network connectivity problems | ||
2. Server-side errors | ||
3. Rate limiting or request timeouts | ||
4. Invalid requests or authentication issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is generally true, it is really a misleading explanation.
This happens when a provider API returns with an error. Most of the time, this means that there API cannot be used in this way, e.g. invalid message structure. The user needs to carefully read the actual error message from the provider and figure out what to do.
## Usage | ||
|
||
```ts | ||
import { APICallError } from '@vercel/ai'; | ||
|
||
try { | ||
// Make an API call using the Vercel AI SDK | ||
} catch (error) { | ||
if (APICallError.isInstance(error)) { | ||
console.error(`API Call Error: ${error.message}`); | ||
console.error(`URL: ${error.url}`); | ||
console.error(`Status Code: ${error.statusCode}`); | ||
console.error(`Is Retryable: ${error.isRetryable}`); | ||
|
||
if (error.isRetryable) { | ||
// Implement retry logic here | ||
} | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just printing the error would do the job already.
console.error(`Status Code: ${error.statusCode}`); | ||
console.error(`Is Retryable: ${error.isRetryable}`); | ||
|
||
if (error.isRetryable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for internal logic (automatic retries) and should not be mentioned
@@ -0,0 +1,47 @@ | |||
--- | |||
title: DownloadError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI_
description: An error thrown when downloading a file fails | ||
--- | ||
|
||
# DownloadError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI_
## How to Resolve It | ||
|
||
To resolve this error: | ||
|
||
1. Check your network connection to ensure there are no connectivity issues. | ||
2. Verify that the AI service is functioning correctly and not experiencing any outages. | ||
3. Review your request parameters to make sure they are valid and complete. | ||
4. If the issue persists, contact the AI service provider's support team for assistance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is caused by provider limitations & bad prompts for the most part, e.g. object generation with perplexity
- [ InvalidMessageRoleError ](/docs/troubleshooting/ai-sdk-errors/invalid-message-role-error) | ||
- [ DownloadError ](/docs/troubleshooting/ai-sdk-errors/download-error) | ||
- [ RetryError ](/docs/troubleshooting/ai-sdk-errors/retry-error) | ||
- [ MessageConversionError ](/docs/troubleshooting/ai-sdk-errors/message-conversion-error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>marker< review end
To resolve this error, you can try the following: | ||
|
||
1. Check the URL: Ensure that the image URL is correct and publicly accessible. | ||
2. Verify network connectivity: Make sure your application has a stable internet connection. | ||
3. Validate content type: Make sure the content type of the file matches what's expected (e.g., image/png, image/jpeg). | ||
|
||
If the issue persists after trying these solutions, you may need to investigate further by examining the specific error details provided in the DownloadError instance, such as the `statusCode` and `statusText`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These instructions are good when you are an end user, however, our "users" build apps that need to generically handle those situations
No description provided.