Skip to content

Commit

Permalink
Update agent component docs (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Sep 17, 2024
1 parent 818a100 commit b350999
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-dots-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/components-react": patch
---

Update agent component docs
11 changes: 3 additions & 8 deletions packages/react/etc/components-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export interface BarVisualizerProps extends React_2.HTMLProps<HTMLDivElement> {
children?: React_2.ReactNode;
// (undocumented)
options?: BarVisualizerOptions;
// Warning: (ae-incompatible-release-tags) The symbol "state" is marked as @beta, but its signature references "VoiceAssistantState" which is marked as @alpha
state?: VoiceAssistantState;
// (undocumented)
trackRef?: TrackReferenceOrPlaceholder;
Expand Down Expand Up @@ -1223,7 +1222,7 @@ export interface UseVisualStableUpdateOptions {
customSortFunction?: (trackReferences: TrackReferenceOrPlaceholder[]) => TrackReferenceOrPlaceholder[];
}

// @alpha
// @beta
export function useVoiceAssistant(): VoiceAssistant;

// @public
Expand Down Expand Up @@ -1257,7 +1256,7 @@ export interface VideoTrackProps extends React_2.VideoHTMLAttributes<HTMLVideoEl
trackRef?: TrackReference;
}

// @alpha (undocumented)
// @beta (undocumented)
export interface VoiceAssistant {
// (undocumented)
agent: RemoteParticipant | undefined;
Expand All @@ -1271,9 +1270,6 @@ export interface VoiceAssistant {
state: VoiceAssistantState;
}

// @alpha (undocumented)
export const VoiceAssistantContext: React_2.Context<VoiceAssistant | undefined>;

// @beta (undocumented)
export function VoiceAssistantControlBar({ controls, saveUserChoices, onDeviceError, ...props }: VoiceAssistantControlBarProps): React_2.JSX.Element;

Expand All @@ -1292,11 +1288,10 @@ export interface VoiceAssistantControlBarProps extends React_2.HTMLAttributes<HT
source: Track.Source;
error: Error;
}) => void;
// @alpha
saveUserChoices?: boolean;
}

// @alpha (undocumented)
// @beta (undocumented)
export type VoiceAssistantState = 'disconnected' | 'connecting' | 'initializing' | 'listening' | 'thinking' | 'speaking';

// @public (undocumented)
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ export {
} from './track-reference-context';

export { FeatureFlags, useFeatureContext, LKFeatureContext } from './feature-context';
export { VoiceAssistantContext } from './voice-assistant-context';
5 changes: 0 additions & 5 deletions packages/react/src/context/voice-assistant-context.ts

This file was deleted.

11 changes: 7 additions & 4 deletions packages/react/src/hooks/useVoiceAssistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useConnectionState } from './useConnectionStatus';
import { useParticipantAttributes } from './useParticipantAttributes';

/**
* @alpha
* @beta
*/
export type VoiceAssistantState =
| 'disconnected'
Expand All @@ -20,7 +20,7 @@ export type VoiceAssistantState =
| 'speaking';

/**
* @alpha
* @beta
*/
export interface VoiceAssistant {
agent: RemoteParticipant | undefined;
Expand All @@ -33,12 +33,15 @@ export interface VoiceAssistant {
const state_attribute = 'voice_assistant.state';

/**
* @alpha
*
* This hook looks for the first agent-participant in the room.
* It assumes that the agent participant is based on the LiveKit VoiceAssistant API and
* returns the most commonly used state vars when interacting with a VoiceAssistant.
* @remarks This hook requires a voice assistant agent running with livekit-agents \>= 0.8.11
* @example
* ```tsx
* const { state, audioTrack, agentTranscriptions, agentAttributes } = useVoiceAssistant();
* ```
* @beta
*/
export function useVoiceAssistant(): VoiceAssistant {
const agent = useRemoteParticipants().find((p) => p.kind === ParticipantKind.AGENT);
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/prefabs/VoiceAssistantControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ export interface VoiceAssistantControlBarProps extends React.HTMLAttributes<HTML
* If `true`, the user's device choices will be persisted.
* This will enables the user to have the same device choices when they rejoin the room.
* @defaultValue true
* @alpha
*/
saveUserChoices?: boolean;
}

/**
* @example
* ```tsx
* <LiveKitRoom ... >
* <VoiceAssistantControlBar />
* </LiveKitRoom>
* ```
* @beta
*/
export function VoiceAssistantControlBar({
Expand Down

0 comments on commit b350999

Please sign in to comment.