-
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.
improve docs & error handling for image parts (#1569)
- Loading branch information
Showing
8 changed files
with
130 additions
and
7 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,6 @@ | ||
--- | ||
'@ai-sdk/provider': patch | ||
'ai': patch | ||
--- | ||
|
||
feat (ai/core): improve image content part error message |
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
10 changes: 10 additions & 0 deletions
10
content/docs/08-troubleshooting/05-ai-sdk-errors/ai-invalid-data-content-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,10 @@ | ||
--- | ||
title: AI_InvalidDataContentError | ||
description: How to fix AI_InvalidDataContentError | ||
--- | ||
|
||
# AI_InvalidDataContentError | ||
|
||
The data content that you have sent in a multi-modal message part is invalid. | ||
|
||
Check out the [prompt examples for multi-modal messages](/docs/ai-sdk-core/prompts#multi-modal-messages). |
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,8 @@ | ||
--- | ||
title: AI SDK Errors | ||
description: Troubleshooting information for common AI SDK errors. | ||
--- | ||
|
||
# AI SDK Errors | ||
|
||
- [ AI_InvalidDataContentError ](/docs/troubleshooting/ai-sdk-errors/ai-invalid-data-content-error) |
29 changes: 29 additions & 0 deletions
29
examples/ai-core/src/generate-text/openai-multimodal-base64.ts
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,29 @@ | ||
import { openai } from '@ai-sdk/openai'; | ||
import { generateText } from 'ai'; | ||
import dotenv from 'dotenv'; | ||
import fs from 'node:fs'; | ||
|
||
dotenv.config(); | ||
|
||
async function main() { | ||
const result = await generateText({ | ||
model: openai.chat('gpt-4-turbo'), | ||
maxTokens: 512, | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: [ | ||
{ type: 'text', text: 'Describe the image in detail.' }, | ||
{ | ||
type: 'image', | ||
image: fs.readFileSync('./data/comic-cat.png').toString('base64'), | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
|
||
console.log(result.text); | ||
} | ||
|
||
main().catch(console.error); |
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