const session = await LanguageModel.create({
initialPrompts: [
{
role: "system",
content: "You are a helpful assistant.",
},
],
});
const response = await session.prompt("What is the capital of France?");
console.log(response); // "The capital of France is Paris."LanguageModel / notebook
LanguageModel
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const session = await LanguageModel.create();
const readableStream = session.promptStreaming("Tell me a short story.");
for await (const chunk of readableStream) {
console.log(chunk);
}