Skip to content

Commit

Permalink
adjust ActionWorker.process to read twilio & vonage IDs from the conv…
Browse files Browse the repository at this point in the history
…o state manager
  • Loading branch information
rjheeta committed Jul 6, 2024
1 parent 6b41941 commit 4921bdf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
22 changes: 13 additions & 9 deletions vocode/streaming/action/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from vocode.streaming.action.abstract_factory import AbstractActionFactory
from vocode.streaming.action.default_factory import DefaultActionFactory
from vocode.streaming.agent.base_agent import ActionResultAgentInput, AgentInput
from vocode.streaming.models.actions import (
ActionInput,
TwilioPhoneConversationActionInput,
VonagePhoneConversationActionInput,
from vocode.streaming.models.actions import ActionInput
from vocode.streaming.utils.state_manager import (
AbstractConversationStateManager,
TwilioPhoneConversationStateManager,
VonagePhoneConversationStateManager,
)
from vocode.streaming.utils.state_manager import AbstractConversationStateManager
from vocode.streaming.utils.worker import (
AbstractWorker,
InterruptibleEvent,
Expand Down Expand Up @@ -49,13 +49,17 @@ async def process(self, item: InterruptibleEvent[ActionInput]):
action_input=action_input,
action_output=action_output,
vonage_uuid=(
action_input.vonage_uuid
if isinstance(action_input, VonagePhoneConversationActionInput)
self.conversation_state_manager.get_vonage_uuid()
if isinstance(
self.conversation_state_manager, VonagePhoneConversationStateManager
)
else None
),
twilio_sid=(
action_input.twilio_sid
if isinstance(action_input, TwilioPhoneConversationActionInput)
self.conversation_state_manager.get_twilio_sid()
if isinstance(
self.conversation_state_manager, TwilioPhoneConversationStateManager
)
else None
),
is_quiet=action.quiet,
Expand Down
6 changes: 6 additions & 0 deletions vocode/streaming/utils/state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def __init__(self, conversation: "VonagePhoneConversation"):
super().__init__(conversation=conversation)
self._vonage_phone_conversation = conversation

def get_vonage_uuid(self):
return self._vonage_phone_conversation.vonage_uuid

def create_vonage_client(self):
return VonageClient(
base_url=self._vonage_phone_conversation.base_url,
Expand All @@ -156,6 +159,9 @@ def __init__(self, conversation: "TwilioPhoneConversation"):

def get_twilio_config(self):
return self._twilio_phone_conversation.twilio_config

def get_twilio_sid(self):
return self._twilio_phone_conversation.twilio_sid

def create_twilio_client(self):
return TwilioClient(
Expand Down

0 comments on commit 4921bdf

Please sign in to comment.