Adapters

Title generation adapters for React Ink.

Adapters customize runtime behavior. They can be passed as options to useLocalRuntime or useRemoteThreadListRuntime.

RemoteThreadListAdapter

Title generation is configured via the generateTitle method on RemoteThreadListAdapter. See the Custom Backend page for a full example.

import type { RemoteThreadListAdapter } from "@assistant-ui/react-ink";
import { createAssistantStream } from "assistant-stream";

const myAdapter: RemoteThreadListAdapter = {
  // ... other methods ...

  async generateTitle(remoteId, unstable_messages) {
    return createAssistantStream(async (controller) => {
      const res = await fetch(`/api/threads/${remoteId}/title`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ messages: unstable_messages }),
      });
      const { title } = await res.json();
      controller.appendText(title);
    });
  },
};

Which option to choose?

ChatModelAdapter + useLocalRuntimeRemoteThreadListAdapter + useRemoteThreadListRuntime
Thread storageIn-memoryYour backend
Message storageIn-memoryIn-memory (can add history adapter for server-side)
Cross-session persistenceNoYes
Setup complexityMinimalModerate
Best forCLI tools, demos, prototypesProduction apps with persistence