Skip to content

Commit

Permalink
added RTVIActionFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
chadbailey59 committed Sep 16, 2024
1 parent 3d4f125 commit ac09eda
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pipecat/processors/frameworks/rtvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

from typing import Any, Awaitable, Callable, Dict, List, Literal, Optional, Union
from pydantic import BaseModel, Field, PrivateAttr, ValidationError
from dataclasses import dataclass

from pipecat.frames.frames import (
BotInterruptionFrame,
BotStartedSpeakingFrame,
BotStoppedSpeakingFrame,
CancelFrame,
DataFrame,
EndFrame,
ErrorFrame,
Frame,
Expand Down Expand Up @@ -116,6 +118,12 @@ class RTVIActionRun(BaseModel):
arguments: Optional[List[RTVIActionRunArgument]] = None


@dataclass
class RTVIActionFrame(DataFrame):
rtvi_action_run: RTVIActionRun
message_id: Optional[str] = "webhook"


class RTVIMessage(BaseModel):
label: Literal["rtvi-ai"] = "rtvi-ai"
type: str
Expand Down Expand Up @@ -377,6 +385,11 @@ async def process_frame(self, frame: Frame, direction: FrameDirection):
await self.push_frame(frame, direction)
elif isinstance(frame, TransportMessageFrame):
await self._message_queue.put(frame)
elif isinstance(frame, RTVIActionFrame):
if not frame.message_id:
# The response isn't going anywhere anyway
frame.message_id = "webhook"
await self._handle_action(frame.message_id, frame.rtvi_action_run)
# Other frames
else:
await self.push_frame(frame, direction)
Expand Down

0 comments on commit ac09eda

Please sign in to comment.