You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-11Lines changed: 47 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Agent Starter for React
2
2
3
-
This is a starter template for [LiveKit Agents](https://docs.livekit.io/agents) that provides a simple voice interface using the[LiveKit JavaScript SDK](https://github.com/livekit/client-sdk-js). It supports [voice](https://docs.livekit.io/agents/start/voice-ai), [transcriptions](https://docs.livekit.io/agents/build/text/), and [virtual avatars](https://docs.livekit.io/agents/integrations/avatar).
3
+
This is a starter template for [LiveKit Agents](https://docs.livekit.io/agents) that provides a simple voice interface using [Agents UI](https://livekit.io/ui) components and[LiveKit JavaScript SDK](https://github.com/livekit/client-sdk-js). It supports [voice](https://docs.livekit.io/agents/start/voice-ai), [transcriptions](https://docs.livekit.io/agents/build/text/), and [virtual avatars](https://docs.livekit.io/agents/integrations/avatar).
@@ -25,27 +25,63 @@ This template is built with Next.js and is free for you to use or modify as you
25
25
26
26
### Project structure
27
27
28
+
This starter uses the [Agents UI](https://livekit.io/ui) components for core UI elements like media controls, audio visualizers, chat transcripts, and providing session data. Shadcn installs components into `components/` folder so you can customize them like any other local component.
29
+
28
30
```
29
31
agent-starter-react/
30
32
├── app/
31
-
│ ├── (app)/
32
33
│ ├── api/
33
-
│ ├── components/
34
-
│ ├── fonts/
35
-
│ ├── globals.css
36
-
│ └── layout.tsx
37
34
├── components/
38
-
│ ├── livekit/
39
-
│ ├── ui/
40
-
│ ├── app.tsx
41
-
│ ├── session-view.tsx
42
-
│ └── welcome.tsx
35
+
│ ├── agents-ui/ - Agents UI components
36
+
│ ├── ai-elements/ - AI Elements components
37
+
│ ├── app/ - App-specific components
38
+
│ ├── ui/ - Primitive shadcn/ui components
39
+
├── fonts/
43
40
├── hooks/
44
41
├── lib/
45
42
├── public/
46
43
└── package.json
47
44
```
48
45
46
+
Business logic lives within the `components/app` folder. It's here where the application's state and behavior is managed and the various Shadcn UI components are composed together.
|`session-view.tsx`| Initializes the application, and LiveKit session. Renders the view controller and session UI including chat transcript, media tiles, and control bar. |
51
+
|`view-controller.tsx`| Manages the transitions between the welcome and session views based on the LiveKit session state. |
52
+
|`welcome-view.tsx`| Renders the welcome UI when the LiveKit session is not connected. |
53
+
|`chat-transcript.tsx`| Manages the chat transcript transitions. |
54
+
|`tile-layout.tsx`| Manages the layout and transition of media tiles in various application states. |
55
+
56
+
### Component usage
57
+
58
+
Most Agents UI components require access to a LiveKit session object for access to values like agent state or audio tracks. A Session object can be created from a [TokenSource](/reference/client-sdk-js/variables/TokenSource.html), and provided by wrapping the component in an [AgentSessionProvider](/reference/components/shadcn/component/agent-session-provider).
59
+
60
+
See [`components/app/app.tsx`](./components/app/app.tsx) for an example of how this is done in this app.
61
+
62
+
### Customizing components
63
+
64
+
Agents UI components, like most Shadcn compopnents, take as many primitive attributes as possible. For example, the [AgentControlBar](/reference/components/shadcn/component/agent-control-bar/page.mdoc) component extends `HTMLAttributes<HTMLDivElement>`, so you can pass any props that a div supports. This makes it easy to extend the component with your own styles or functionality.
65
+
66
+
You can edit any Agents UI component's source code in the `components/agents-ui` directory. For style changes, we recommend passing in tailwind classes to override the default styles. Take a look at the source code to get a sense of how to override a component's default styles.
67
+
68
+
### Updating components
69
+
70
+
To update the Agents UI components to the latest publication, run the following command:
71
+
72
+
```bash
73
+
pnpm shadcn:install
74
+
```
75
+
76
+
> [!NOTE]
77
+
> The CLI will ask before overwriting any modified files so you can avoid losing any customizations you might have made.
0 commit comments