e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
"use client";
|
|
|
|
// Mirrors examples/with-react-ink/src/app.tsx; keep in sync.
|
|
import { useMemo } from "react";
|
|
import { Box, Text } from "ink";
|
|
import {
|
|
AssistantRuntimeProvider,
|
|
StatusBarPrimitive,
|
|
useAui,
|
|
} from "@assistant-ui/react-ink";
|
|
import {
|
|
useChatRuntime,
|
|
AssistantChatTransport,
|
|
} from "@assistant-ui/react-ai-sdk";
|
|
import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
|
|
import { Thread } from "./thread";
|
|
|
|
const CHAT_API =
|
|
process.env.NEXT_PUBLIC_CHAT_ENDPOINT_URL ??
|
|
(process.env.NODE_ENV === "development"
|
|
? "http://localhost:3000/api/chat"
|
|
: "https://www.assistant-ui.com/api/chat");
|
|
|
|
const MODEL_NAME = "assistant-ui";
|
|
|
|
export const InkApp = () => {
|
|
const transport = useMemo(
|
|
() => new AssistantChatTransport({ api: CHAT_API }),
|
|
[],
|
|
);
|
|
const runtime = useChatRuntime({
|
|
transport,
|
|
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
|
|
});
|
|
const aui = useAui();
|
|
|
|
return (
|
|
<AssistantRuntimeProvider aui={aui} runtime={runtime}>
|
|
<Box flexDirection="column" padding={1}>
|
|
<Box>
|
|
<Text bold color="cyan">
|
|
{MODEL_NAME}
|
|
</Text>
|
|
<Text dimColor>{" ~/assistant-ui"}</Text>
|
|
</Box>
|
|
<StatusBarPrimitive.Root>
|
|
<Text dimColor>
|
|
model: <StatusBarPrimitive.ModelName name={MODEL_NAME} /> ·{" "}
|
|
<StatusBarPrimitive.MessageCount /> · <StatusBarPrimitive.Status />
|
|
</Text>
|
|
</StatusBarPrimitive.Root>
|
|
<Box marginTop={1}>
|
|
<Thread />
|
|
</Box>
|
|
</Box>
|
|
</AssistantRuntimeProvider>
|
|
);
|
|
};
|