-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for images in UserMessages (#546)
This adds support for passing images as inputs to OpenAI models. They can be embedded in `<UserMessage>`s using the existing `<Image>` tag. By default `OpenAIChatModel` passes images for models that supports it, but this can be forced (or denied) by setting the `includeImages` props explicitly.
- Loading branch information
1 parent
e7b3e2e
commit 2df9c5e
Showing
7 changed files
with
138 additions
and
22 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ChatCompletion, UserMessage } from 'ai-jsx/core/completion'; | ||
import { Image } from 'ai-jsx/core/image-gen'; | ||
import { showInspector } from 'ai-jsx/core/inspector'; | ||
import { OpenAI } from 'ai-jsx/lib/openai'; | ||
|
||
function App() { | ||
return ( | ||
<OpenAI chatModel="gpt-4-turbo"> | ||
<ChatCompletion> | ||
<UserMessage> | ||
What do the following images have in common? | ||
<Image url="https://upload.wikimedia.org/wikipedia/commons/8/89/Apollo_11_bootprint.jpg" detail="low" /> | ||
<Image | ||
url="https://upload.wikimedia.org/wikipedia/commons/3/36/PIA00563-Viking1-FirstColorImage-19760721.jpg" | ||
detail="low" | ||
/> | ||
</UserMessage> | ||
</ChatCompletion> | ||
</OpenAI> | ||
); | ||
} | ||
|
||
showInspector(<App />); |