Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeremyphilemon
Copy link
Contributor

No description provided.

@@ -1,10 +1,73 @@
---
title: AI_InvalidDataContentError
description: How to fix AI_InvalidDataContentError
title: InvalidDataContentError
Copy link
Collaborator

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

Comment on lines +58 to +73
## 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
}
}
```
Copy link
Collaborator

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.

Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI_

Comment on lines +10 to +15
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
Copy link
Collaborator

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.

Comment on lines +41 to +60
## 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
}
}
}
```
Copy link
Collaborator

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) {
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI_

Comment on lines +16 to +23
## 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.
Copy link
Collaborator

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)
Copy link
Collaborator

@lgrammel lgrammel Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>marker< review end

Comment on lines +23 to +29
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`.
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants