Add RTVI transcripts, align styling
This commit is contained in:
@@ -63,6 +63,14 @@ class ChatbotClient {
|
|||||||
log(message) {
|
log(message) {
|
||||||
const entry = document.createElement('div');
|
const entry = document.createElement('div');
|
||||||
entry.textContent = `${new Date().toISOString()} - ${message}`;
|
entry.textContent = `${new Date().toISOString()} - ${message}`;
|
||||||
|
|
||||||
|
// Add styling based on message type
|
||||||
|
if (message.startsWith('User: ')) {
|
||||||
|
entry.style.color = '#2196F3'; // blue for user
|
||||||
|
} else if (message.startsWith('Bot: ')) {
|
||||||
|
entry.style.color = '#4CAF50'; // green for bot
|
||||||
|
}
|
||||||
|
|
||||||
this.debugLog.appendChild(entry);
|
this.debugLog.appendChild(entry);
|
||||||
this.debugLog.scrollTop = this.debugLog.scrollHeight;
|
this.debugLog.scrollTop = this.debugLog.scrollHeight;
|
||||||
console.log(message);
|
console.log(message);
|
||||||
@@ -221,6 +229,23 @@ class ChatbotClient {
|
|||||||
this.log(`Bot ready: ${JSON.stringify(data)}`);
|
this.log(`Bot ready: ${JSON.stringify(data)}`);
|
||||||
this.setupMediaTracks();
|
this.setupMediaTracks();
|
||||||
},
|
},
|
||||||
|
// Transcript events
|
||||||
|
onUserTranscript: (data) => {
|
||||||
|
// Only log final transcripts
|
||||||
|
if (data.final) {
|
||||||
|
this.log(`User: ${data.text}`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onBotTranscript: (data) => {
|
||||||
|
this.log(`Bot: ${data.text}`);
|
||||||
|
},
|
||||||
|
// Error handling
|
||||||
|
onMessageError: (error) => {
|
||||||
|
console.log('Message error:', error);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.log('Error:', error);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ button:disabled {
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.debug-panel h3 {
|
||||||
|
margin: 0 0 10px 0;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
#debug-log {
|
#debug-log {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@@ -87,4 +93,6 @@ button:disabled {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import { useRef, useCallback } from 'react';
|
import { useRef, useCallback } from 'react';
|
||||||
import { Participant, RTVIEvent, TransportState } from 'realtime-ai';
|
import {
|
||||||
|
Participant,
|
||||||
|
RTVIEvent,
|
||||||
|
TransportState,
|
||||||
|
TranscriptData,
|
||||||
|
BotLLMTextData,
|
||||||
|
} from 'realtime-ai';
|
||||||
import { useRTVIClient, useRTVIClientEvent } from 'realtime-ai-react';
|
import { useRTVIClient, useRTVIClientEvent } from 'realtime-ai-react';
|
||||||
import './DebugDisplay.css';
|
import './DebugDisplay.css';
|
||||||
|
|
||||||
@@ -12,6 +18,14 @@ export function DebugDisplay() {
|
|||||||
|
|
||||||
const entry = document.createElement('div');
|
const entry = document.createElement('div');
|
||||||
entry.textContent = `${new Date().toISOString()} - ${message}`;
|
entry.textContent = `${new Date().toISOString()} - ${message}`;
|
||||||
|
|
||||||
|
// Add styling based on message type
|
||||||
|
if (message.startsWith('User: ')) {
|
||||||
|
entry.style.color = '#2196F3'; // blue for user
|
||||||
|
} else if (message.startsWith('Bot: ')) {
|
||||||
|
entry.style.color = '#4CAF50'; // green for bot
|
||||||
|
}
|
||||||
|
|
||||||
debugLogRef.current.appendChild(entry);
|
debugLogRef.current.appendChild(entry);
|
||||||
debugLogRef.current.scrollTop = debugLogRef.current.scrollHeight;
|
debugLogRef.current.scrollTop = debugLogRef.current.scrollHeight;
|
||||||
}, []);
|
}, []);
|
||||||
@@ -97,6 +111,30 @@ export function DebugDisplay() {
|
|||||||
}, [client, log])
|
}, [client, log])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Log transcripts
|
||||||
|
useRTVIClientEvent(
|
||||||
|
RTVIEvent.UserTranscript,
|
||||||
|
useCallback(
|
||||||
|
(data: TranscriptData) => {
|
||||||
|
// Only log final transcripts
|
||||||
|
if (data.final) {
|
||||||
|
log(`User: ${data.text}`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[log]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
useRTVIClientEvent(
|
||||||
|
RTVIEvent.BotTranscript,
|
||||||
|
useCallback(
|
||||||
|
(data: BotLLMTextData) => {
|
||||||
|
log(`Bot: ${data.text}`);
|
||||||
|
},
|
||||||
|
[log]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="debug-panel">
|
<div className="debug-panel">
|
||||||
<h3>Debug Info</h3>
|
<h3>Debug Info</h3>
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ from pipecat.pipeline.runner import PipelineRunner
|
|||||||
from pipecat.pipeline.task import PipelineParams, PipelineTask
|
from pipecat.pipeline.task import PipelineParams, PipelineTask
|
||||||
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
||||||
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||||
|
from pipecat.processors.frameworks.rtvi import (
|
||||||
|
RTVIBotTranscriptionProcessor,
|
||||||
|
RTVIUserTranscriptionProcessor,
|
||||||
|
)
|
||||||
from pipecat.services.elevenlabs import ElevenLabsTTSService
|
from pipecat.services.elevenlabs import ElevenLabsTTSService
|
||||||
from pipecat.services.openai import OpenAILLMService
|
from pipecat.services.openai import OpenAILLMService
|
||||||
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
||||||
@@ -143,11 +147,21 @@ async def main():
|
|||||||
|
|
||||||
ta = TalkingAnimation()
|
ta = TalkingAnimation()
|
||||||
|
|
||||||
|
# RTVI
|
||||||
|
|
||||||
|
# This will emit UserTranscript events.
|
||||||
|
rtvi_user_transcription = RTVIUserTranscriptionProcessor()
|
||||||
|
|
||||||
|
# This will emit BotTranscript events.
|
||||||
|
rtvi_bot_transcription = RTVIBotTranscriptionProcessor()
|
||||||
|
|
||||||
pipeline = Pipeline(
|
pipeline = Pipeline(
|
||||||
[
|
[
|
||||||
transport.input(),
|
transport.input(),
|
||||||
|
rtvi_user_transcription,
|
||||||
context_aggregator.user(),
|
context_aggregator.user(),
|
||||||
llm,
|
llm,
|
||||||
|
rtvi_bot_transcription,
|
||||||
tts,
|
tts,
|
||||||
ta,
|
ta,
|
||||||
transport.output(),
|
transport.output(),
|
||||||
|
|||||||
Reference in New Issue
Block a user