@tavus/cvi-ui 0.0.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.prettierrc.js +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +91 -0
  4. package/dev-components/components/cvi-provider/index.tsx +9 -0
  5. package/dev-components/hooks/README.md +499 -0
  6. package/dev-components/hooks/cvi-events-hooks.tsx +168 -0
  7. package/dev-components/hooks/use-cvi-call.tsx +24 -0
  8. package/dev-components/hooks/use-local-camera.tsx +20 -0
  9. package/dev-components/hooks/use-local-microphone.tsx +20 -0
  10. package/dev-components/hooks/use-local-screenshare.tsx +32 -0
  11. package/dev-components/hooks/use-remote-participant-ids.tsx +7 -0
  12. package/dev-components/hooks/use-replica-ids.tsx +9 -0
  13. package/dev-components/hooks/use-request-permissions.tsx +24 -0
  14. package/dev-components/hooks/use-start-haircheck.tsx +60 -0
  15. package/dist/index.js +237334 -0
  16. package/dist/types/cli/add.d.ts +20 -0
  17. package/dist/types/cli/info.d.ts +2 -0
  18. package/dist/types/cli/init.d.ts +23 -0
  19. package/dist/types/components/highlighter.d.ts +6 -0
  20. package/dist/types/components/logger.d.ts +8 -0
  21. package/dist/types/components/spinner.d.ts +4 -0
  22. package/dist/types/constants/components.d.ts +59 -0
  23. package/dist/types/constants/config.d.ts +5 -0
  24. package/dist/types/constants/errors.d.ts +5 -0
  25. package/dist/types/constants/frameworks.d.ts +39 -0
  26. package/dist/types/index.d.ts +1 -0
  27. package/dist/types/preflights/preflight-add.d.ts +15 -0
  28. package/dist/types/preflights/preflight-init.d.ts +9 -0
  29. package/dist/types/utils/add-components.d.ts +5 -0
  30. package/dist/types/utils/get-config.d.ts +51 -0
  31. package/dist/types/utils/get-package-info.d.ts +2 -0
  32. package/dist/types/utils/get-package-manager.d.ts +4 -0
  33. package/dist/types/utils/get-project-info.d.ts +10 -0
  34. package/dist/types/utils/handle-error.d.ts +1 -0
  35. package/dist/types/utils/resolve-components-tree.d.ts +4 -0
  36. package/dist/types/utils/resolve-import.d.ts +2 -0
  37. package/dist/types/utils/update-dependencies.d.ts +4 -0
  38. package/dist/types/utils/update-files.d.ts +14 -0
  39. package/dist/typescript-DhnEO4aV.js +12 -0
  40. package/dist/typescript-XxXP1Woc.js +14 -0
  41. package/eslint.config.js +12 -0
  42. package/package.json +67 -0
  43. package/prepare-scripts/convert-to-js.js +152 -0
  44. package/prepare-scripts/create-templates.js +265 -0
  45. package/rollup.config.js +28 -0
  46. package/src/cli/add.ts +124 -0
  47. package/src/cli/info.ts +21 -0
  48. package/src/cli/init.ts +131 -0
  49. package/src/components/highlighter.ts +8 -0
  50. package/src/components/logger.ts +22 -0
  51. package/src/components/spinner.ts +13 -0
  52. package/src/constants/config.ts +7 -0
  53. package/src/constants/errors.ts +5 -0
  54. package/src/constants/frameworks.ts +40 -0
  55. package/src/index.ts +26 -0
  56. package/src/preflights/preflight-add.ts +56 -0
  57. package/src/preflights/preflight-init.ts +77 -0
  58. package/src/utils/add-components.ts +52 -0
  59. package/src/utils/get-config.ts +60 -0
  60. package/src/utils/get-package-info.ts +14 -0
  61. package/src/utils/get-package-manager.ts +45 -0
  62. package/src/utils/get-project-info.ts +144 -0
  63. package/src/utils/handle-error.ts +34 -0
  64. package/src/utils/resolve-components-tree.ts +35 -0
  65. package/src/utils/update-dependencies.ts +37 -0
  66. package/src/utils/update-files.ts +212 -0
  67. package/tsconfig.json +23 -0
package/.prettierrc.js ADDED
@@ -0,0 +1,24 @@
1
+ /** @type {import('prettier').Config} */
2
+ export default {
3
+ semi: true,
4
+ singleQuote: true,
5
+ tabWidth: 2,
6
+ trailingComma: 'es5',
7
+ printWidth: 100,
8
+ bracketSpacing: true,
9
+ arrowParens: 'always',
10
+ endOfLine: 'lf',
11
+ // Remove comments
12
+ proseWrap: 'never',
13
+ htmlWhitespaceSensitivity: 'css',
14
+ embeddedLanguageFormatting: 'off',
15
+ singleAttributePerLine: false,
16
+ bracketSameLine: false,
17
+ jsxSingleQuote: false,
18
+ quoteProps: 'as-needed',
19
+ jsxBracketSameLine: false,
20
+ requirePragma: false,
21
+ insertPragma: false,
22
+ useTabs: true,
23
+ vueIndentScriptAndStyle: false,
24
+ };
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tavus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # Tavus CVI Component Library
2
+
3
+ A CLI tool for installing and managing CVI (Conversational Video Interface) components for React applications. This library provides pre-built components for creating real-time multimodal video conversations with AI replicas.
4
+
5
+ ## Usage
6
+
7
+ **Initialize the project**:
8
+
9
+ ```bash
10
+ npx @tavus/cvi-ui init
11
+ ```
12
+
13
+ This will:
14
+
15
+ - Create a `cvi-components.json` configuration file
16
+ - Prompt for TypeScript preference
17
+ - Install the necessary dependencies
18
+
19
+ **Add components to your project**:
20
+
21
+ ```bash
22
+ npx @tavus/cvi-ui add conversation
23
+ ```
24
+
25
+ **Wrap your app with the CVI provider**:
26
+
27
+ ```tsx
28
+ import { CVIProvider } from './components/cvi/components/cvi-provider';
29
+
30
+ function App() {
31
+ return (
32
+ <CVIProvider>
33
+ {/* Your app content */}
34
+ </CVIProvider>
35
+ );
36
+ }
37
+ ```
38
+
39
+ **Add conversation components**:
40
+
41
+ ```tsx
42
+ import { Conversation } from './components/cvi/components/conversation';
43
+
44
+ function Call() {
45
+ return (
46
+ <div>
47
+ <Conversation {...conversationProps} />
48
+ </div>
49
+ );
50
+ }
51
+ ```
52
+
53
+ ## Available Components
54
+
55
+ ### Core Components
56
+
57
+ - **`cvi-provider`** - Main provider component that wraps your app with CVI context
58
+
59
+ ### Hooks
60
+
61
+ #### Core Call Management
62
+
63
+ - **`use-cvi-call`** – Provides basic join and leave functionality for CVI calls.
64
+ - **`use-start-haircheck`** – Manages device-permission checks and initializes the camera to start a haircheck session.
65
+
66
+ #### Media Controls
67
+
68
+ - **`use-local-camera`** – Manages local camera state and toggle functionality.
69
+ - **`use-local-microphone`** – Manages local microphone state and toggle functionality.
70
+ - **`use-local-screenshare`** – Manages screen-share state and toggle functionality.
71
+ - **`use-request-permissions`** – Requests permissions and handles audio processing setup.
72
+
73
+ #### Participant Management
74
+
75
+ - **`use-replica-ids`** – Retrieves Tavus–replica participant IDs.
76
+ - **`use-remote-participant-ids`** – Retrieves remote participant IDs.
77
+
78
+ #### Conversation & Events
79
+
80
+ - **`use-observable-event`** – Listens for CVI events.
81
+ - **`use-send-app-message`** – Sends CVI app messages.
82
+
83
+ ## License
84
+
85
+ MIT License - see the [LICENSE](LICENSE) file for details.
86
+
87
+ ## Related Links
88
+
89
+ - [CVI Documentation](https://docs.tavus.io/sections/conversational-video-interface/cvi-overview)
90
+ - [Tavus Examples](https://github.com/Tavus-Engineering/tavus-examples)
91
+
@@ -0,0 +1,9 @@
1
+ import { DailyProvider } from "@daily-co/daily-react";
2
+
3
+ export const CVIProvider = ({ children }: { children: React.ReactNode }) => {
4
+ return (
5
+ <DailyProvider>
6
+ {children}
7
+ </DailyProvider>
8
+ )
9
+ }
@@ -0,0 +1,499 @@
1
+ # CVI Hooks Documentation
2
+
3
+ This documentation is organized by functionality to help you find the right hook for your needs.
4
+
5
+ ## Table of Contents
6
+
7
+ ### 🔧 Core Call Management
8
+
9
+ - [useCVICall](#usecvicall) - Basic call join/leave functionality
10
+ - [useStartHaircheck](#usestarthaircheck) - Device permissions and camera initialization
11
+
12
+ ### 🎥 Media Controls
13
+
14
+ - [useLocalCamera](#uselocalcamera) - Camera state and toggle
15
+ - [useLocalMicrophone](#uselocalmicrophone) - Microphone state and toggle
16
+ - [useLocalScreenshare](#uselocalscreenshare) - Screen sharing state and toggle
17
+ - [useRequestPermissions](#userequestpermissions) - Permission requests with audio processing
18
+
19
+ ### 👥 Participant Management
20
+
21
+ - [useReplicaIDs](#usereplicaiids) - Get Tavus replica participant IDs
22
+ - [useRemoteParticipantIDs](#useremoteparticipantiids) - Get remote participant IDs
23
+
24
+ ### 💬 Conversation & Events
25
+
26
+ - [useObservableEvent](#useobservableevent) - Listen for CVI conversation events
27
+ - [useSendAppMessage](#usesendappmessage) - Send CVI app messages
28
+
29
+ ---
30
+
31
+ ## 🔧 Core Call Management
32
+
33
+ ### useCVICall
34
+
35
+ A React hook that provides basic call management functionality.
36
+
37
+ #### Purpose
38
+
39
+ - Manages call join/leave operations
40
+ - Provides access to the Daily call instance
41
+
42
+ #### Return Values
43
+
44
+ | Property | Type | Description |
45
+ | ----------- | --------------------------- | ---------------------------------- |
46
+ | `joinCall` | `({ url: string }) => void` | Function to join a call by URL |
47
+ | `leaveCall` | `() => void` | Function to leave the current call |
48
+
49
+ #### Usage
50
+
51
+ ```tsx
52
+ import { useCVICall } from './hooks/use-cvi-call';
53
+
54
+ const CallManager = () => {
55
+ const { joinCall, leaveCall } = useCVICall();
56
+
57
+ const handleJoin = () => {
58
+ joinCall({ url: 'https://your-daily-room-url' });
59
+ };
60
+
61
+ return (
62
+ <div>
63
+ <button onClick={handleJoin}>Join Call</button>
64
+ <button onClick={leaveCall}>Leave Call</button>
65
+ </div>
66
+ );
67
+ };
68
+ ```
69
+
70
+ ### useStartHaircheck
71
+
72
+ A React hook that manages device permissions and camera initialization for the hair-check component.
73
+
74
+ #### Purpose
75
+
76
+ - Monitors device permission states
77
+ - Starts camera and microphone when appropriate
78
+ - Provides permission state for UI conditional rendering
79
+ - Handles permission request flow
80
+
81
+ #### Return Values
82
+
83
+ | Property | Type | Description |
84
+ | --- | --- | --- |
85
+ | `isPermissionsPrompt` | `boolean` | Browser is prompting for device permission |
86
+ | `isPermissionsLoading` | `boolean` | Permissions are being processed or camera is initializing |
87
+ | `isPermissionsGranted` | `boolean` | Device permission granted |
88
+ | `isPermissionsDenied` | `boolean` | Device permission denied |
89
+ | `requestPermissions` | `() => void` | Function to request camera and microphone permissions |
90
+
91
+ #### Usage
92
+
93
+ ```tsx
94
+ import { useStartHaircheck } from './hooks/use-start-haircheck';
95
+
96
+ const HairCheckComponent = () => {
97
+ const {
98
+ isPermissionsPrompt,
99
+ isPermissionsLoading,
100
+ isPermissionsGranted,
101
+ isPermissionsDenied,
102
+ requestPermissions
103
+ } = useStartHaircheck();
104
+
105
+ useEffect(() => {
106
+ requestPermissions();
107
+ }, []);
108
+
109
+ return (
110
+ <div>
111
+ {isPermissionsLoading && <InitializingSpinner />}
112
+ {isPermissionsPrompt && <PermissionPrompt />}
113
+ {isPermissionsDenied && <PermissionDeniedMessage />}
114
+ {isPermissionsGranted && <VideoPreview />}
115
+ </div>
116
+ );
117
+ };
118
+ ```
119
+
120
+ ---
121
+
122
+ ## 🎥 Media Controls
123
+
124
+ ### useLocalCamera
125
+
126
+ A React hook that provides local camera state and toggle functionality.
127
+
128
+ #### Purpose
129
+
130
+ - Manages local camera state (on/off)
131
+ - Tracks camera permission and ready state
132
+
133
+ #### Return Values
134
+
135
+ | Property | Type | Description |
136
+ | ---------------- | ------------ | -------------------------------------- |
137
+ | `onToggleCamera` | `() => void` | Function to toggle camera on/off |
138
+ | `isCamReady` | `boolean` | Camera permission is granted and ready |
139
+ | `isCamMuted` | `boolean` | Camera is currently turned off |
140
+
141
+ #### Usage
142
+
143
+ ```tsx
144
+ import { useLocalCamera } from './hooks/use-local-camera';
145
+
146
+ const CameraControls = () => {
147
+ const { onToggleCamera, isCamReady, isCamMuted } = useLocalCamera();
148
+
149
+ return (
150
+ <button
151
+ onClick={onToggleCamera}
152
+ disabled={!isCamReady}
153
+ >
154
+ {isCamMuted ? 'Turn Camera On' : 'Turn Camera Off'}
155
+ </button>
156
+ );
157
+ };
158
+ ```
159
+
160
+ ### useLocalMicrophone
161
+
162
+ A React hook that provides local microphone state and toggle functionality.
163
+
164
+ #### Purpose
165
+
166
+ - Manages local microphone state (on/off)
167
+ - Tracks microphone permission and ready state
168
+
169
+ #### Return Values
170
+
171
+ | Property | Type | Description |
172
+ | -------------------- | ------------ | ------------------------------------------ |
173
+ | `onToggleMicrophone` | `() => void` | Function to toggle microphone on/off |
174
+ | `isMicReady` | `boolean` | Microphone permission is granted and ready |
175
+ | `isMicMuted` | `boolean` | Microphone is currently turned off |
176
+
177
+ #### Usage
178
+
179
+ ```tsx
180
+ import { useLocalMicrophone } from './hooks/use-local-microphone';
181
+
182
+ const MicrophoneControls = () => {
183
+ const { onToggleMicrophone, isMicReady, isMicMuted } = useLocalMicrophone();
184
+
185
+ return (
186
+ <button
187
+ onClick={onToggleMicrophone}
188
+ disabled={!isMicReady}
189
+ >
190
+ {isMicMuted ? 'Unmute' : 'Mute'}
191
+ </button>
192
+ );
193
+ };
194
+ ```
195
+
196
+ ### useLocalScreenshare
197
+
198
+ A React hook that provides local screen sharing state and toggle functionality.
199
+
200
+ #### Purpose
201
+
202
+ - Manages screen sharing state (on/off)
203
+ - Provides screen sharing toggle function
204
+ - Handles screen share start/stop with optimized display media options
205
+
206
+ #### Return Values
207
+
208
+ | Property | Type | Description |
209
+ | --------------------- | ------------ | ------------------------------------------ |
210
+ | `onToggleScreenshare` | `() => void` | Function to toggle screen sharing on/off |
211
+ | `isScreenSharing` | `boolean` | Whether screen sharing is currently active |
212
+
213
+ #### Display Media Options
214
+
215
+ When starting screen share, the hook uses the following optimized settings:
216
+
217
+ - **Audio**: Disabled (false)
218
+ - **Self Browser Surface**: Excluded
219
+ - **Surface Switching**: Included
220
+ - **Video Resolution**: 1920x1080
221
+
222
+ #### Usage
223
+
224
+ ```tsx
225
+ import { useLocalScreenshare } from './hooks/use-local-screenshare';
226
+
227
+ const ScreenShareControls = () => {
228
+ const { onToggleScreenshare, isScreenSharing } = useLocalScreenshare();
229
+
230
+ return (
231
+ <button
232
+ onClick={onToggleScreenshare}
233
+ className={isScreenSharing ? 'active' : ''}
234
+ >
235
+ {isScreenSharing ? 'Stop Sharing' : 'Share Screen'}
236
+ </button>
237
+ );
238
+ };
239
+ ```
240
+
241
+ ### useRequestPermissions
242
+
243
+ A React hook that requests camera and microphone permissions with optimized audio processing settings.
244
+
245
+ #### Purpose
246
+
247
+ - Requests camera and microphone permissions from the user
248
+ - Starts camera and audio with specific configuration
249
+ - Applies noise cancellation audio processing
250
+ - Provides a clean interface for permission requests
251
+
252
+ #### Return Values
253
+
254
+ | Property | Type | Description |
255
+ | --- | --- | --- |
256
+ | `requestPermissions` | `() => Promise<DailyDeviceInfos>` | Function to request camera and microphone permissions |
257
+
258
+ #### Configuration
259
+
260
+ When requesting permissions, the hook uses the following settings:
261
+
262
+ - **Video**: Started on (startVideoOff: false)
263
+ - **Audio**: Started on (startAudioOff: false)
264
+ - **Audio Source**: Default system audio input
265
+ - **Audio Processing**: Noise cancellation enabled
266
+
267
+ #### Usage
268
+
269
+ ```tsx
270
+ import { useRequestPermissions } from './hooks/use-request-permissions';
271
+
272
+ const PermissionRequest = () => {
273
+ const requestPermissions = useRequestPermissions();
274
+
275
+ const handleRequestPermissions = async () => {
276
+ try {
277
+ await requestPermissions();
278
+ console.log('Permissions granted successfully');
279
+ } catch (error) {
280
+ console.error('Failed to get permissions:', error);
281
+ }
282
+ };
283
+
284
+ return (
285
+ <button onClick={handleRequestPermissions}>
286
+ Request Camera & Microphone Permissions
287
+ </button>
288
+ );
289
+ };
290
+ ```
291
+
292
+ ---
293
+
294
+ ## 👥 Participant Management
295
+
296
+ ### useReplicaIDs
297
+
298
+ A React hook that returns the IDs of all Tavus replica participants in a call.
299
+
300
+ #### Purpose
301
+
302
+ - Filters and returns participant IDs where `user_id` includes 'tavus-replica'
303
+
304
+ #### Return Value
305
+
306
+ - `string[]` — Array of replica participant IDs
307
+
308
+ #### Usage
309
+
310
+ ```tsx
311
+ import { useReplicaIDs } from './hooks/use-replica-ids';
312
+
313
+ const ids = useReplicaIDs();
314
+ // ids is an array of participant IDs for Tavus replicas
315
+ ```
316
+
317
+ ### useRemoteParticipantIDs
318
+
319
+ A React hook that returns the IDs of all remote participants in a call.
320
+
321
+ #### Purpose
322
+
323
+ - Returns participant IDs for all remote participants (excluding local user)
324
+
325
+ #### Return Value
326
+
327
+ - `string[]` — Array of remote participant IDs
328
+
329
+ #### Usage
330
+
331
+ ```tsx
332
+ import { useRemoteParticipantIDs } from './hooks/use-remote-participant-ids';
333
+
334
+ const remoteIds = useRemoteParticipantIDs();
335
+ // remoteIds is an array of remote participant IDs
336
+ ```
337
+
338
+ ---
339
+
340
+ ## 💬 Conversation & Events
341
+
342
+ ### useObservableEvent
343
+
344
+ A React hook that listens for CVI app messages and provides a callback mechanism for handling various conversation events.
345
+
346
+ #### Purpose
347
+
348
+ - Listens for app messages from the Daily.co call mapped to CVI events
349
+ - Handles various conversation event types (utterances, tool calls, speaking events, etc.)
350
+ - Provides type-safe event handling for CVI interactions
351
+
352
+ #### Parameters
353
+
354
+ | Parameter | Type | Description |
355
+ | --- | --- | --- |
356
+ | `callback` | `(event: AppMessage<T>['data']) => void` | Function called when app messages are received |
357
+
358
+ #### Event Types
359
+
360
+ This hook handles all CVI conversation events. For detailed information about each event type, see the [Tavus Interactions Protocol Documentation](https://docs.tavus.io/sections/conversational-video-interface/live-interactions).
361
+
362
+ #### Usage
363
+
364
+ ```tsx
365
+ import { useObservableEvent } from './hooks/cvi-events-hooks';
366
+
367
+ const ConversationHandler = () => {
368
+ useObservableEvent((event) => {
369
+ switch (event.event_type) {
370
+ case 'conversation.utterance':
371
+ console.log('Speech:', event.properties.speech);
372
+ break;
373
+ case 'conversation.replica.started_speaking':
374
+ console.log('Replica started speaking');
375
+ break;
376
+ case 'conversation.user.stopped_speaking':
377
+ console.log('User stopped speaking');
378
+ break;
379
+ }
380
+ });
381
+
382
+ return <div>Listening for conversation events...</div>;
383
+ };
384
+ ```
385
+
386
+ ### useSendAppMessage
387
+
388
+ A React hook that provides a function to send CVI app messages to other participants in the call.
389
+
390
+ #### Purpose
391
+
392
+ - Sends various types of conversation messages to the CVI system
393
+ - Supports echo, respond, interrupt, and context management messages
394
+ - Provides type-safe message sending with proper validation
395
+ - Enables real-time communication with Tavus replicas and conversation management
396
+
397
+ #### Return Value
398
+
399
+ - `(message: SendAppMessageProps) => void` - Function that sends the message when called
400
+
401
+ #### Message Types
402
+
403
+ This hook supports all CVI interaction types. For detailed information about each interaction type and their properties, see the [Tavus Interactions Protocol Documentation](https://docs.tavus.io/sections/conversational-video-interface/live-interactions).
404
+
405
+ #### Usage
406
+
407
+ ```tsx
408
+ import { useSendAppMessage } from './hooks/cvi-events-hooks';
409
+
410
+ const MessageSender = () => {
411
+ const sendMessage = useSendAppMessage();
412
+
413
+ // Send a text echo
414
+ const sendTextEcho = () => {
415
+ sendMessage({
416
+ message_type: "conversation",
417
+ event_type: "conversation.echo",
418
+ conversation_id: "conv-123",
419
+ properties: {
420
+ modality: "text",
421
+ text: "Hello, world!",
422
+ audio: "",
423
+ sample_rate: 16000,
424
+ inference_id: "inf-456",
425
+ done: true
426
+ }
427
+ });
428
+ };
429
+
430
+ // Send a text response
431
+ const sendResponse = () => {
432
+ sendMessage({
433
+ message_type: "conversation",
434
+ event_type: "conversation.respond",
435
+ conversation_id: "conv-123",
436
+ properties: {
437
+ text: "This is my response to the conversation."
438
+ }
439
+ });
440
+ };
441
+
442
+ // Interrupt the current conversation
443
+ const interruptConversation = () => {
444
+ sendMessage({
445
+ message_type: "conversation",
446
+ event_type: "conversation.interrupt",
447
+ conversation_id: "conv-123"
448
+ });
449
+ };
450
+
451
+ // Overwrite LLM context
452
+ const updateContext = () => {
453
+ sendMessage({
454
+ message_type: "conversation",
455
+ event_type: "conversation.overwrite_llm_context",
456
+ conversation_id: "conv-123",
457
+ properties: {
458
+ context: "New conversation context that replaces the existing one."
459
+ }
460
+ });
461
+ };
462
+
463
+ // Append to LLM context
464
+ const appendContext = () => {
465
+ sendMessage({
466
+ message_type: "conversation",
467
+ event_type: "conversation.append_llm_context",
468
+ conversation_id: "conv-123",
469
+ properties: {
470
+ context: "Additional context to append to the existing conversation."
471
+ }
472
+ });
473
+ };
474
+
475
+ // Adjust sensitivity settings
476
+ const adjustSensitivity = () => {
477
+ sendMessage({
478
+ message_type: "conversation",
479
+ event_type: "conversation.sensitivity",
480
+ conversation_id: "conv-123",
481
+ properties: {
482
+ participant_pause_sensitivity: "medium",
483
+ participant_interrupt_sensitivity: "high"
484
+ }
485
+ });
486
+ };
487
+
488
+ return (
489
+ <div>
490
+ <button onClick={sendTextEcho}>Send Text Echo</button>
491
+ <button onClick={sendResponse}>Send Response</button>
492
+ <button onClick={interruptConversation}>Interrupt</button>
493
+ <button onClick={updateContext}>Update Context</button>
494
+ <button onClick={appendContext}>Append Context</button>
495
+ <button onClick={adjustSensitivity}>Adjust Sensitivity</button>
496
+ </div>
497
+ );
498
+ };
499
+ ```