Support text-only agent (#131)
This commit is contained in:
parent
00448e7c89
commit
5416e0fb9f
@ -207,7 +207,7 @@ export default function Playground({
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const chatTileContent = useMemo(() => {
|
const chatTileContent = useMemo(() => {
|
||||||
if (voiceAssistant.audioTrack) {
|
if (voiceAssistant.agent) {
|
||||||
return (
|
return (
|
||||||
<TranscriptionTile
|
<TranscriptionTile
|
||||||
agentAudioTrack={voiceAssistant.audioTrack}
|
agentAudioTrack={voiceAssistant.audioTrack}
|
||||||
@ -216,7 +216,7 @@ export default function Playground({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return <></>;
|
return <></>;
|
||||||
}, [config.settings.theme_color, voiceAssistant.audioTrack]);
|
}, [config.settings.theme_color, voiceAssistant.audioTrack, voiceAssistant.agent]);
|
||||||
|
|
||||||
const handleRpcCall = useCallback(async () => {
|
const handleRpcCall = useCallback(async () => {
|
||||||
if (!voiceAssistant.agent || !room) return;
|
if (!voiceAssistant.agent || !room) return;
|
||||||
|
|||||||
@ -17,10 +17,10 @@ export function TranscriptionTile({
|
|||||||
agentAudioTrack,
|
agentAudioTrack,
|
||||||
accentColor,
|
accentColor,
|
||||||
}: {
|
}: {
|
||||||
agentAudioTrack: TrackReferenceOrPlaceholder;
|
agentAudioTrack?: TrackReferenceOrPlaceholder;
|
||||||
accentColor: string;
|
accentColor: string;
|
||||||
}) {
|
}) {
|
||||||
const agentMessages = useTrackTranscription(agentAudioTrack);
|
const agentMessages = useTrackTranscription(agentAudioTrack || undefined);
|
||||||
const localParticipant = useLocalParticipant();
|
const localParticipant = useLocalParticipant();
|
||||||
const localMessages = useTrackTranscription({
|
const localMessages = useTrackTranscription({
|
||||||
publication: localParticipant.microphoneTrack,
|
publication: localParticipant.microphoneTrack,
|
||||||
@ -36,16 +36,19 @@ export function TranscriptionTile({
|
|||||||
|
|
||||||
// store transcripts
|
// store transcripts
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
agentMessages.segments.forEach((s) =>
|
if (agentAudioTrack) {
|
||||||
transcripts.set(
|
agentMessages.segments.forEach((s) =>
|
||||||
s.id,
|
transcripts.set(
|
||||||
segmentToChatMessage(
|
s.id,
|
||||||
s,
|
segmentToChatMessage(
|
||||||
transcripts.get(s.id),
|
s,
|
||||||
agentAudioTrack.participant
|
transcripts.get(s.id),
|
||||||
|
agentAudioTrack.participant
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
);
|
}
|
||||||
|
|
||||||
localMessages.segments.forEach((s) =>
|
localMessages.segments.forEach((s) =>
|
||||||
transcripts.set(
|
transcripts.set(
|
||||||
s.id,
|
s.id,
|
||||||
@ -59,8 +62,9 @@ export function TranscriptionTile({
|
|||||||
|
|
||||||
const allMessages = Array.from(transcripts.values());
|
const allMessages = Array.from(transcripts.values());
|
||||||
for (const msg of chatMessages) {
|
for (const msg of chatMessages) {
|
||||||
const isAgent =
|
const isAgent = agentAudioTrack
|
||||||
msg.from?.identity === agentAudioTrack.participant?.identity;
|
? msg.from?.identity === agentAudioTrack.participant?.identity
|
||||||
|
: msg.from?.identity !== localParticipant.localParticipant.identity;
|
||||||
const isSelf =
|
const isSelf =
|
||||||
msg.from?.identity === localParticipant.localParticipant.identity;
|
msg.from?.identity === localParticipant.localParticipant.identity;
|
||||||
let name = msg.from?.name;
|
let name = msg.from?.name;
|
||||||
@ -86,9 +90,10 @@ export function TranscriptionTile({
|
|||||||
transcripts,
|
transcripts,
|
||||||
chatMessages,
|
chatMessages,
|
||||||
localParticipant.localParticipant,
|
localParticipant.localParticipant,
|
||||||
agentAudioTrack.participant,
|
agentAudioTrack?.participant,
|
||||||
agentMessages.segments,
|
agentMessages.segments,
|
||||||
localMessages.segments,
|
localMessages.segments,
|
||||||
|
agentAudioTrack,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user