Skip to content

Commit

Permalink
Add an RTVIProcessor to the simple-chatbot pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-daily committed Dec 20, 2024
1 parent 6e0d3ae commit e5981e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/simple-chatbot/server/bot-gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
from pipecat.processors.frameworks.rtvi import (
RTVIProcessor,
RTVIConfig,
RTVIBotTranscriptionProcessor,
RTVIMetricsProcessor,
RTVISpeakingProcessor,
Expand Down Expand Up @@ -179,9 +181,13 @@ async def main():
# This will send `metrics` messages.
rtvi_metrics = RTVIMetricsProcessor()

# Handles RTVI messages from the client
rtvi = RTVIProcessor(config=RTVIConfig(config=[]))

pipeline = Pipeline(
[
transport.input(),
rtvi,
context_aggregator.user(),
llm,
rtvi_speaking,
Expand All @@ -204,6 +210,10 @@ async def main():
)
await task.queue_frame(quiet_frame)

@rtvi.event_handler("on_client_ready")
async def on_client_ready(rtvi):
await rtvi.set_bot_ready()

@transport.event_handler("on_first_participant_joined")
async def on_first_participant_joined(transport, participant):
await transport.capture_participant_transcription(participant["id"])
Expand Down
10 changes: 10 additions & 0 deletions examples/simple-chatbot/server/bot-openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
from pipecat.processors.frameworks.rtvi import (
RTVIProcessor,
RTVIBotTranscriptionProcessor,
RTVIMetricsProcessor,
RTVISpeakingProcessor,
RTVIUserTranscriptionProcessor,
RTVIConfig,
)
from pipecat.services.elevenlabs import ElevenLabsTTSService
from pipecat.services.openai import OpenAILLMService
Expand Down Expand Up @@ -201,9 +203,13 @@ async def main():
# This will send `metrics` messages.
rtvi_metrics = RTVIMetricsProcessor()

# Handles RTVI messages from the client
rtvi = RTVIProcessor(config=RTVIConfig(config=[]))

pipeline = Pipeline(
[
transport.input(),
rtvi,
rtvi_speaking,
rtvi_user_transcription,
context_aggregator.user(),
Expand All @@ -227,6 +233,10 @@ async def main():
)
await task.queue_frame(quiet_frame)

@rtvi.event_handler("on_client_ready")
async def on_client_ready(rtvi):
await rtvi.set_bot_ready()

@transport.event_handler("on_first_participant_joined")
async def on_first_participant_joined(transport, participant):
await transport.capture_participant_transcription(participant["id"])
Expand Down

0 comments on commit e5981e6

Please sign in to comment.