Public
Edited
Feb 14, 2023
Paused
2 forks
5 stars
Insert cell
Insert cell
Insert cell
import {
viewof openaiApiKey,
completions,
text_edits,
code_edits,
images
} from "@osteele/openai-api"
Insert cell
Insert cell
viewof openaiApiKey
Insert cell
Insert cell
## 3. Text Completion

Use `completions(prompt)` to create a completion for the provided (string) prompt.

The following example wraps the result in `md` in order to format the output.
Insert cell
md`${await completions("Ten ways of using ObservableHQ:")}`

Insert cell
Insert cell
Insert cell
image_urls = await images("A cute baby sea otter", { n: 3, size: 256 })
Insert cell
html`<div style="display:flex;flex-wrap:wrap; justify-content:space-between">${image_urls.map(
(url) => `<img style="padding:5px" src="${url}"/>`
)}</div>`
Insert cell
Insert cell
text_edits("What day of the wek is it?") // OpenAI will correct the typo in "wek"
Insert cell
Insert cell
html`<pre>${await code_edits("print a list of string lengths", {
input: "def print_lengths"
})}</pre>`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more