Usage
Code
'use client';import { useSession, useVoiceAssistant } from '@livekit/components-react';import { AgentSessionProvider } from '@/components/agents-ui/agent-session-provider';import { AgentChatTranscript } from '@/components/agents-ui/agent-chat-transcript';const TOKEN_SOURCE = TokenSource.sandboxTokenServer(process.env.MY_LK_SANDBOX_TOKEN_SERVER_ID);const MESSAGES = [{id: '1',timestamp: new Date().toISOString(),from: { isLocal: false },message: 'Hi, how are you?',},{id: '2',timestamp: new Date().toISOString(),from: { isLocal: true },message: "I'm good, thank you!",},{id: '3',timestamp: new Date().toISOString(),from: { isLocal: false },message: 'This is a longer message that should wrap to the next line.',},{id: '4',timestamp: new Date().toISOString(),from: { isLocal: true },message: "Great I'm responding with an even longer message to see how it wraps.",},];export funnction Demo() {const { state } = useVoiceAssistant();return (<AgentChatTranscriptagentState={state}messages={MESSAGES}/>);}export default function DemoWrapper({ session }) {const session = useSession(TOKEN_SOURCE);return (<AgentSessionProvider session={session}><Demo /></AgentSessionProvider>);}
Features
- Displays the agent's chat transcript in a styled list
- Supports both plain text and markdown formatting
- Automatically scrolls to the latest message
- Handles message updates and deletions
Installation
pnpm dlx shadcn@latest add @agents-ui/agent-chat-transcript
Props
| Prop name | Type | Default |
|---|---|---|
agentState? | enum | – |
messages? | ReceivedMessage[] | [] |
className? | string | – |
...props? | ComponentProps<'div'> | |