-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add back support for image parts in messages.
- Loading branch information
Showing
3 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
examples/ai-core/src/generate-text/openai-compatible-togetherai-image.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,30 @@ | ||
import 'dotenv/config'; | ||
import { createOpenAICompatible } from '@ai-sdk/openai-compatible'; | ||
import { generateText } from 'ai'; | ||
import fs from 'node:fs'; | ||
|
||
async function main() { | ||
const togetherai = createOpenAICompatible({ | ||
apiKeyEnvVarName: 'TOGETHER_AI_API_KEY', | ||
baseURL: 'https://api.together.xyz/v1', | ||
name: 'togetherai', | ||
}); | ||
// const model = togetherai.chatModel('google/gemma-2b-it'); | ||
const model = togetherai.chatModel('mistralai/Mixtral-8x7B-Instruct-v0.1'); | ||
const result = await generateText({ | ||
model, | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: [ | ||
{ type: 'text', text: 'Describe the image in detail.' }, | ||
{ type: 'image', image: fs.readFileSync('./data/comic-cat.png') }, | ||
], | ||
}, | ||
], | ||
}); | ||
|
||
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