LanguageModel API

The language model API allows you to create a conversation with the language model.

import AI from '@aibrow/web'
const session = await AI.AIBrow.LanguageModel.create();

// Prompt the model and wait for the whole result to come back.
const result = await session.prompt("Write me a poem.");
console.log(result);

// Prompt the model and stream the result:
const stream = await session.promptStreaming("Write me an extra-long poem.");
for await (const chunk of stream) {
  console.log(chunk);
}

Continuing a conversation

import AI from '@aibrow/web'
const session = await AI.AIBrow.LanguageModel.create();

// Ask the intial question
const result = await session.prompt("Tell me about the weather");
console.log(result);

// Prompt the same session again to continue the same conversation
const result2 = await session.prompt("Can you expand on this?");
console.log(result2);

System prompts & initial prompts

You can use system prompts to customize the behaviour of the model as well as initial prompts from a previous conversation

Demos

Email subject generator

Spreadsheet autofill

Last updated