Skip to content

The Open Standard for Generative UI

1.3 KB
Raw Blame
"use client";
import "@openuidev/react-ui/styles/index.css";

import { OpenUIWordmark } from "@/components/openui-wordmark";
import { OPENUI_LOGO, STARTERS } from "@/lib/starters";
import {
  AgentInterface,
  fetchLLM,
  useThemeModePreference,
  vercelAIAdapter,
  vercelAIMessageFormat,
  WelcomeMascot,
} from "@openuidev/react-ui";
import { openuiLibrary } from "@openuidev/react-ui/genui-lib";


const llm = fetchLLM({
  url: "/api/chat",
  streamAdapter: vercelAIAdapter(),
  messageFormat: vercelAIMessageFormat,
});

export default function Home() {
  // Follows the system theme until the footer toggle is first used, then
  // remembers the choice.
  const { setPreference, mode } = useThemeModePreference();

  return (
    <AgentInterface
      llm={llm}
      componentLibrary={openuiLibrary}
      logoUrl={OPENUI_LOGO}
      theme={{ mode }}
      starters={STARTERS}
    >
      <AgentInterface.SidebarHeader agentName={<OpenUIWordmark mode={mode} />} />
      <AgentInterface.SidebarFooter>
        <AgentInterface.ThemeModeToggle mode={mode} onModeChange={setPreference} />
      </AgentInterface.SidebarFooter>
      <AgentInterface.ThreadHeader />
      <AgentInterface.Welcome
        image={<WelcomeMascot />}
        title="What's on your mind today?"
        starterVariant="card"
        glowAnimation
      />
    </AgentInterface>
  );
}