-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQUASHED: AUTO-COMMIT-demos-openai-vision-paint.md,AUTO-COMMIT-doc-journal-2024-05-23.md-index.md,AUTO-COMMIT-doc-journal-2024-05-23.md-squence-A-B.png,AUTO-COMMIT-src-components-tools-lively-image-editor.html,AUTO-COMMIT-src-components-tools-lively-image-editor.js,AUTO-COMMIT-src-components-tools-openai-audio-chat.js,
- Loading branch information
1 parent
3ca078a
commit 3df5ad4
Showing
6 changed files
with
86 additions
and
11 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,56 @@ | ||
# Paint | ||
|
||
|
||
<script> | ||
import OpenAI from "demos/openai/openai.js" | ||
|
||
|
||
let paint = await (<lively-image-editor id="editor"></lively-image-editor>) | ||
paint.clear() | ||
|
||
|
||
async function view() { | ||
let url = paint.canvas.toDataURL() | ||
let blob = await fetch(url).then(r => r.blob()) | ||
let image = await lively.files.readBlobAsDataURL(blob) | ||
let prompt = { | ||
"model": "gpt-4o", | ||
"max_tokens": 500, | ||
"temperature": 0.1, | ||
"top_p": 1, | ||
"n": 1, | ||
"stream": false, | ||
"stop": "VANILLA", | ||
"messages": [ | ||
{ "role": "system", "content": "You are an AI chat bot!" }, | ||
{ "role": "user", "content": [ | ||
{ | ||
"type": "text", | ||
"text": "What’s in this image?" | ||
}, | ||
{ | ||
"type": "image_url", | ||
"image_url": { | ||
"url": image, | ||
"detail": "low" // high | ||
} | ||
} | ||
]} | ||
] | ||
} | ||
|
||
let json = await OpenAI.openAIRequest(prompt).then(r => r.json()) | ||
result.textContent = json.choices[0].message.content | ||
} | ||
|
||
let result = <div></div> | ||
|
||
let pane = <div> | ||
{paint} | ||
<button click={() => view()}>view</button> | ||
{result} | ||
</div> | ||
|
||
|
||
pane | ||
</script> |
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 @@ | ||
## 2024-05-23 Vision Paint OpenAI example | ||
*Author: @JensLincke* | ||
|
||
<browse://demos/openai/vision-paint.md> | ||
|
||
![](squence-A-B.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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