From 810dc30d3d513c5b8547e9374677463e62f5e47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Sun, 19 May 2024 09:39:34 -0700 Subject: [PATCH] examples: fix examples to use LLMFullResponseEndFrame --- CHANGELOG.md | 2 +- examples/foundational/11-sound-effects.py | 4 ++-- examples/moondream-chatbot/bot.py | 2 +- examples/simple-chatbot/bot.py | 2 +- examples/storytelling-chatbot/src/processors.py | 10 +++++++--- src/pipecat/pipeline/parallel_pipeline.py | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a26ebfbb3..10b964a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added initial interruptions support. The assitant contexts (or aggregators) +- Added initial interruptions support. The assistant contexts (or aggregators) should now be placed after the output transport. This way, only the completed spoken context is added to the assistant context. diff --git a/examples/foundational/11-sound-effects.py b/examples/foundational/11-sound-effects.py index 292a89052..c8d113c30 100644 --- a/examples/foundational/11-sound-effects.py +++ b/examples/foundational/11-sound-effects.py @@ -13,7 +13,7 @@ import wave from pipecat.frames.frames import ( Frame, AudioRawFrame, - LLMResponseEndFrame, + LLMFullResponseEndFrame, LLMMessagesFrame, ) from pipecat.pipeline.pipeline import Pipeline @@ -59,7 +59,7 @@ for file in sound_files: class OutboundSoundEffectWrapper(FrameProcessor): async def process_frame(self, frame: Frame, direction: FrameDirection): - if isinstance(frame, LLMResponseEndFrame): + if isinstance(frame, LLMFullResponseEndFrame): await self.push_frame(sounds["ding1.wav"]) # In case anything else downstream needs it await self.push_frame(frame, direction) diff --git a/examples/moondream-chatbot/bot.py b/examples/moondream-chatbot/bot.py index b09f4345d..76948be55 100644 --- a/examples/moondream-chatbot/bot.py +++ b/examples/moondream-chatbot/bot.py @@ -66,7 +66,7 @@ talking_frame = SpriteFrame(images=sprites) class TalkingAnimation(FrameProcessor): """ This class starts a talking animation when it receives an first AudioFrame, - and then returns to a "quiet" sprite when it sees a LLMResponseEndFrame. + and then returns to a "quiet" sprite when it sees a TTSStoppedFrame. """ def __init__(self): diff --git a/examples/simple-chatbot/bot.py b/examples/simple-chatbot/bot.py index 87d1ca37f..eb15dc05a 100644 --- a/examples/simple-chatbot/bot.py +++ b/examples/simple-chatbot/bot.py @@ -56,7 +56,7 @@ talking_frame = SpriteFrame(images=sprites) class TalkingAnimation(FrameProcessor): """ This class starts a talking animation when it receives an first AudioFrame, - and then returns to a "quiet" sprite when it sees a LLMResponseEndFrame. + and then returns to a "quiet" sprite when it sees a TTSStoppedFrame. """ def __init__(self): diff --git a/examples/storytelling-chatbot/src/processors.py b/examples/storytelling-chatbot/src/processors.py index 30528af94..18428eb72 100644 --- a/examples/storytelling-chatbot/src/processors.py +++ b/examples/storytelling-chatbot/src/processors.py @@ -2,7 +2,11 @@ import re from async_timeout import timeout -from pipecat.frames.frames import Frame, LLMResponseEndFrame, TextFrame, UserStoppedSpeakingFrame +from pipecat.frames.frames import ( + Frame, + LLMFullResponseEndFrame, + TextFrame, + UserStoppedSpeakingFrame) from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.transports.services.daily import DailyTransportMessageFrame @@ -128,9 +132,9 @@ class StoryProcessor(FrameProcessor): # Clear the buffer self._text = "" - # End of LLM response + # End of a full LLM response # Driven by the prompt, the LLM should have asked the user for input - elif isinstance(frame, LLMResponseEndFrame): + elif isinstance(frame, LLMFullResponseEndFrame): # We use a different frame type, as to avoid image generation ingest await self.push_frame(StoryPromptFrame(self._text)) self._text = "" diff --git a/src/pipecat/pipeline/parallel_pipeline.py b/src/pipecat/pipeline/parallel_pipeline.py index 5dd840281..22ffdfdf2 100644 --- a/src/pipecat/pipeline/parallel_pipeline.py +++ b/src/pipecat/pipeline/parallel_pipeline.py @@ -63,7 +63,7 @@ class ParallelPipeline(FrameProcessor): if not isinstance(processors, list): raise TypeError(f"ParallelPipeline argument {processors} is not a list") - # We add a source at before the pipeline and a sink after. + # We will add a source before the pipeline and a sink after. source = Source(self._up_queue) sink = Sink(self._down_queue) self._sources.append(source)