diff --git a/pipecat/learn/pipeline-termination.mdx b/pipecat/learn/pipeline-termination.mdx index 85b08787..76d88fa6 100644 --- a/pipecat/learn/pipeline-termination.mdx +++ b/pipecat/learn/pipeline-termination.mdx @@ -54,7 +54,7 @@ from pipecat.frames.frames import EndFrame, TTSSpeakFrame await task.queue_frame(EndFrame()) ``` -Push an `EndTaskFrame` upstream from inside your pipeline: +Push an `EndTaskFrame` downstream from inside your pipeline: ```python # From inside a function call @@ -65,7 +65,7 @@ async def end_conversation(params: FunctionCallParams): await params.llm.push_frame(TTSSpeakFrame("Have a nice day!")) # Signal that the task should end after processing this frame - await params.llm.push_frame(EndTaskFrame(), FrameDirection.UPSTREAM) + await params.llm.push_frame(EndTaskFrame(), FrameDirection.DOWNSTREAM) ``` **How graceful termination works:** @@ -186,7 +186,7 @@ async def check_conversation_complete(params: FunctionCallParams): if conversation_complete: await params.llm.push_frame(TTSSpeakFrame("Thank you for using our service!")) - await params.llm.push_frame(EndTaskFrame(), FrameDirection.UPSTREAM) + await params.llm.push_frame(EndTaskFrame(), FrameDirection.DOWNSTREAM) await params.result_callback({"status": "complete" if conversation_complete else "continuing"}) ``` @@ -232,9 +232,8 @@ async def process_frame(self, frame: Frame, direction: FrameDirection): **Solution:** Use the appropriate frame type and direction: ```python -# From inside the pipeline, push upstream to reach the source -await self.push_frame(EndTaskFrame(), FrameDirection.UPSTREAM) -await self.push_frame(CancelTaskFrame(), FrameDirection.UPSTREAM) +await self.push_frame(EndTaskFrame(), FrameDirection.DOWNSTREAM) +await self.push_frame(CancelTaskFrame(), FrameDirection.DOWNSTREAM) # The pipeline source will then convert these to proper termination frames # and push them downstream through the entire pipeline