Public
Edited
Aug 9, 2023
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// (await import("https://episphere.github.io/gpt/jonas/export.js")).check4key('<your-API-key>')
Insert cell
Insert cell
//jonas = import("http://localhost:8000/gpt/jonas/export.js")
jonas = import("https://episphere.github.io/gpt/jonas/export.js")
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Insert cell
matchModels = models.data.filter((x) => x.id.match(pat))
Insert cell
Insert cell
cp0 = await jonas.completions(
"Say with gentle sarcasm that this is the best GPT SDK ever!"
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
gpt3 = import("https://episphere.github.io/gpt/export.js")
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
hello = gpt3.completions("hello")
Insert cell
choices = hello.choices
Insert cell
ola = gpt3.completions("olá")
Insert cell
Insert cell
euro2016 = gpt3.completions(
JSON.stringify([
{
role: "user",
content: "where was the UEFA Euro in 2016?"
},
{
role: "user",
content: "who won?"
},
{
role: "user",
content: "what was the final score?"
}
])
)
Insert cell
euro2016.choices[0].message.content
Insert cell
Insert cell
oncoGenes = gpt3.completions(
JSON.stringify([
{
role: "user",
content: "what are oncogenes?"
},
{
role: "user",
content: "Please summarize it in a sentence with less than 12 words"
}
])
)
Insert cell
Insert cell
uefa = gpt3.completions(
JSON.stringify([
{
role: "system",
content: "answer as a 12 word poem"
},
{
role: "assistant",
content: "the year is 2016"
},
{
role: "user",
content: "who won uefa euro?"
},
{
role: "user",
content: "at what time in the game was that goal scored?"
}
])
)
Insert cell
## Embeddings
Insert cell
helloWorld = gpt3.embeddings("Hello world !")
Insert cell
Plotly = require("https://cdn.plot.ly/plotly-latest.min.js")
Insert cell
Insert cell
{
let xx = (
await gpt3.embeddings(
"Now is the winter of our discontent; Made glorious summer by this sun of York;"
)
).data[0].embedding;
let yy = (
await gpt3.embeddings(
"Now is the winter of our discontent; Made glorious summer by this sun of York;"
)
).data[0].embedding;
let diff = xx.map((xi, i) => yy[i] - xi);
let div = DOM.element("div");
Plotly.newPlot(
div,
[
{
x: xx,
y: yy,
mode: "markers",
type: "scatter",
marker: { size: 4, color: "rgba(0, 0, 255,0.5)" },
name: "value"
},
{
x: xx,
y: diff,
mode: "markers",
type: "scatter",
marker: { size: 4, color: "rgba(255, 0, 0,0.5)" },
name: "difference"
}
],
{
xaxis: { range: [-0.05, 0.05] },
yaxis: { range: [-0.05, 0.05] }
}
);
return div;
}
Insert cell
Insert cell
{
let xx = (
await gpt3.embeddings(
"Now is the winter of our discontent; Made glorious summer by this sun of York;"
)
).data[0].embedding;
let yy = (
await gpt3.embeddings(
"Now is the winter of our discontent; Made glorious summer by this sun of York;"
)
).data[0].embedding;
// embed
let diff = xx.map((xi, i) => yy[i] - xi);
let div = DOM.element("div");
Plotly.newPlot(div, [
{
x: xx.slice(1),
y: xx.slice(0, -1),
mode: "markers",
type: "scatter",
marker: { size: 4, color: "rgba(0, 0, 255,0.1)" }
},
{
x: yy.slice(1),
y: yy.slice(0, -1),
mode: "markers",
type: "scatter",
marker: { size: 4, color: "rgba(255, 0, 0,0.1)" }
}
]);
return div;
}
Insert cell
(await import("https://episphere.github.io/gpt/jonas/export.js")).check4key()
Insert cell
await (
await import("https://episphere.github.io/gpt/min.js")
).embeddings("hello world")
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