Skip to content

Add go_to_page

Pass destinations and navigate to AssistedProvider. With both, the provider lends go_to_page and show_links. Without either, it lends neither.

destinations maps a page’s name to its path. A path with :id takes an id. From examples/app/app/assistant.tsx:

const destinations = {
home: "/",
orders: "/orders",
order: "/orders/:id",
customers: "/customers",
settings: "/settings",
};

Define it at module scope, as the example does.

navigate opens a path. In Next.js it is router.push. From examples/app/app/assistant.tsx:

<AssistedProvider
runtime={runtime}
destinations={destinations}
navigate={(path) => router.push(path)}
>
  • go_to_page({ to, id? }) calls navigate, waits up to 5 seconds for the assisted page to change, and answers Opened <path>. with the note of the page now open.
  • show_links({ items }) shows a card of links, each a destination with a title and a one-line gist. A click calls navigate.

The universal instructions tell the assistant to use go_to_page when the user asks to go somewhere or the work is on another page. The answers and errors are in the model context reference.