examples: fix examples to use LLMFullResponseEndFrame
This commit is contained in:
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### 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
|
should now be placed after the output transport. This way, only the completed
|
||||||
spoken context is added to the assistant context.
|
spoken context is added to the assistant context.
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import wave
|
|||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
Frame,
|
Frame,
|
||||||
AudioRawFrame,
|
AudioRawFrame,
|
||||||
LLMResponseEndFrame,
|
LLMFullResponseEndFrame,
|
||||||
LLMMessagesFrame,
|
LLMMessagesFrame,
|
||||||
)
|
)
|
||||||
from pipecat.pipeline.pipeline import Pipeline
|
from pipecat.pipeline.pipeline import Pipeline
|
||||||
@@ -59,7 +59,7 @@ for file in sound_files:
|
|||||||
class OutboundSoundEffectWrapper(FrameProcessor):
|
class OutboundSoundEffectWrapper(FrameProcessor):
|
||||||
|
|
||||||
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
||||||
if isinstance(frame, LLMResponseEndFrame):
|
if isinstance(frame, LLMFullResponseEndFrame):
|
||||||
await self.push_frame(sounds["ding1.wav"])
|
await self.push_frame(sounds["ding1.wav"])
|
||||||
# In case anything else downstream needs it
|
# In case anything else downstream needs it
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ talking_frame = SpriteFrame(images=sprites)
|
|||||||
class TalkingAnimation(FrameProcessor):
|
class TalkingAnimation(FrameProcessor):
|
||||||
"""
|
"""
|
||||||
This class starts a talking animation when it receives an first AudioFrame,
|
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):
|
def __init__(self):
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ talking_frame = SpriteFrame(images=sprites)
|
|||||||
class TalkingAnimation(FrameProcessor):
|
class TalkingAnimation(FrameProcessor):
|
||||||
"""
|
"""
|
||||||
This class starts a talking animation when it receives an first AudioFrame,
|
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):
|
def __init__(self):
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import re
|
|||||||
|
|
||||||
from async_timeout import timeout
|
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.processors.frame_processor import FrameDirection, FrameProcessor
|
||||||
from pipecat.transports.services.daily import DailyTransportMessageFrame
|
from pipecat.transports.services.daily import DailyTransportMessageFrame
|
||||||
|
|
||||||
@@ -128,9 +132,9 @@ class StoryProcessor(FrameProcessor):
|
|||||||
# Clear the buffer
|
# Clear the buffer
|
||||||
self._text = ""
|
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
|
# 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
|
# We use a different frame type, as to avoid image generation ingest
|
||||||
await self.push_frame(StoryPromptFrame(self._text))
|
await self.push_frame(StoryPromptFrame(self._text))
|
||||||
self._text = ""
|
self._text = ""
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class ParallelPipeline(FrameProcessor):
|
|||||||
if not isinstance(processors, list):
|
if not isinstance(processors, list):
|
||||||
raise TypeError(f"ParallelPipeline argument {processors} is not a 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)
|
source = Source(self._up_queue)
|
||||||
sink = Sink(self._down_queue)
|
sink = Sink(self._down_queue)
|
||||||
self._sources.append(source)
|
self._sources.append(source)
|
||||||
|
|||||||
Reference in New Issue
Block a user