Public
Edited
Jun 9, 2024
2 forks
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
settings = ({
temperature: 0.7,
max_tokens: 500,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
on_input = {
// Tick the game when new "adventure_input" arrives
const masked_input = adventure_input.split("\n").slice(-1);
const adventure_response = game.advance(masked_input).join(" ");
const score = parseInt(
(/(\d+)/.exec(
adventure
.makeState(JSON.parse(JSON.stringify(game)))
.advance("score")
.find((x) => x.startsWith("SCORE"))
) || ["0", "0"])[1]
);

// Record history
viewof game_history.value.push({
input: adventure_input,
response: adventure_response,
score,
turn: (viewof game_history.value.slice(-1)[0]?.turn || 0) + 1
});
viewof game_history.dispatchEvent(new Event("input"));

// Render to HTML
mutable output =
mutable output + "<br>> " + adventure_input + "<br>" + adventure_response;

if (game.state == "init_yesno") {
// Auto-play the instructions part
viewof adventure_input[0].value = "no";
viewof adventure_input.dispatchEvent(new Event("submit"));
} else {
viewof adventure_input.value = "";
}
return `${adventure_input} -> ${adventure_response}`;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more