-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (ai/core): throw NoImageGeneratedError from generateImage when n…
…o predictions are returned (#4395) Co-authored-by: Lars Grammel <[email protected]>
- Loading branch information
Showing
21 changed files
with
696 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'ai': patch | ||
'@ai-sdk/fireworks': patch | ||
'@ai-sdk/google-vertex': patch | ||
'@ai-sdk/openai': patch | ||
'@ai-sdk/provider': patch | ||
'@ai-sdk/replicate': patch | ||
--- | ||
|
||
feat (ai/core): throw NoImageGeneratedError from generateImage when no predictions are returned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
content/docs/07-reference/05-ai-sdk-errors/ai-no-image-generated-error.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: AI_NoImageGeneratedError | ||
description: Learn how to fix AI_NoImageGeneratedError | ||
--- | ||
|
||
# AI_NoImageGeneratedError | ||
|
||
This error occurs when the AI provider fails to generate an image. | ||
It can arise due to the following reasons: | ||
|
||
- The model failed to generate a response. | ||
- The model generated an invalid response. | ||
|
||
## Properties | ||
|
||
- `message`: The error message. | ||
- `responses`: Metadata about the image model responses, including timestamp, model, and headers. | ||
- `cause`: The cause of the error. You can use this for more detailed error handling. | ||
|
||
## Checking for this Error | ||
|
||
You can check if an error is an instance of `AI_NoImageGeneratedError` using: | ||
|
||
```typescript | ||
import { generateImage, NoImageGeneratedError } from 'ai'; | ||
|
||
try { | ||
await generateImage({ model, prompt }); | ||
} catch (error) { | ||
if (NoImageGeneratedError.isInstance(error)) { | ||
console.log('NoImageGeneratedError'); | ||
console.log('Cause:', error.cause); | ||
console.log('Responses:', error.responses); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.