Skip to content

Commit

Permalink
action factory
Browse files Browse the repository at this point in the history
  • Loading branch information
sethgw committed Jul 19, 2023
1 parent e0b7ece commit 1001f04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions vocode/streaming/action/factory.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from vocode.streaming.action.base_action import BaseAction
from vocode.streaming.action.nylas_send_email import NylasSendEmail
from vocode.streaming.action.transfer_call import TransferCall
from vocode.streaming.models.actions import ActionType


class ActionFactory:
def create_action(self, action_type: str) -> BaseAction:
if action_type == ActionType.NYLAS_SEND_EMAIL:
return NylasSendEmail(should_respond=True)
elif action_type == ActionType.TRANSFER_CALL:
return TransferCall(to_phone="+15555555555")
else:
raise Exception("Invalid action type")
12 changes: 8 additions & 4 deletions vocode/streaming/models/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class ActionType(str, Enum):
BASE = "action_base"
NYLAS_SEND_EMAIL = "action_nylas_send_email"
TRANSFER_CALL = "action_transfer_call"


ParametersType = TypeVar("ParametersType", bound=BaseModel)
Expand All @@ -16,13 +17,16 @@ class ActionInput(BaseModel, Generic[ParametersType]):
conversation_id: str
params: ParametersType


class FunctionFragment(BaseModel):
name: str
arguments: str
name: str
arguments: str


class FunctionCall(BaseModel):
name: str
arguments: str
name: str
arguments: str


class VonagePhoneCallActionInput(ActionInput[ParametersType]):
vonage_uuid: str
Expand Down

0 comments on commit 1001f04

Please sign in to comment.