diff --git a/playground/streaming/agent/chat.py b/playground/streaming/agent/chat.py index d539ac474..31dc70706 100644 --- a/playground/streaming/agent/chat.py +++ b/playground/streaming/agent/chat.py @@ -30,8 +30,7 @@ from vocode.streaming.utils import create_conversation_id -class ShoutActionConfig(ActionConfig): - type = "shout" +class ShoutActionConfig(ActionConfig, type="shout"): num_exclamation_marks: int diff --git a/vocode/streaming/action/nylas_send_email.py b/vocode/streaming/action/nylas_send_email.py index 004b48d8b..08be384cf 100644 --- a/vocode/streaming/action/nylas_send_email.py +++ b/vocode/streaming/action/nylas_send_email.py @@ -10,8 +10,8 @@ ) -class NylasSendEmailActionConfig(ActionConfig): - type = ActionType.NYLAS_SEND_EMAIL +class NylasSendEmailActionConfig(ActionConfig, type=ActionType.NYLAS_SEND_EMAIL): + pass class NylasSendEmailParameters(BaseModel): diff --git a/vocode/streaming/models/actions.py b/vocode/streaming/models/actions.py index ba57c4674..cc764a048 100644 --- a/vocode/streaming/models/actions.py +++ b/vocode/streaming/models/actions.py @@ -1,10 +1,7 @@ from enum import Enum from typing import Generic, TypeVar from pydantic import BaseModel - - -class ActionConfig(BaseModel): - type: str +from vocode.streaming.models.model import TypedModel class ActionType(str, Enum): @@ -12,6 +9,10 @@ class ActionType(str, Enum): NYLAS_SEND_EMAIL = "action_nylas_send_email" +class ActionConfig(TypedModel, type=ActionType.BASE): + pass + + ParametersType = TypeVar("ParametersType", bound=BaseModel) diff --git a/vocode/streaming/models/model.py b/vocode/streaming/models/model.py index 256134f13..42a4590db 100644 --- a/vocode/streaming/models/model.py +++ b/vocode/streaming/models/model.py @@ -8,6 +8,11 @@ def __init__(self, **data): if isinstance(value, dict): if "type" in value: data[key] = TypedModel.parse_obj(value) + if isinstance(value, list): + for i, v in enumerate(value): + if isinstance(v, dict): + if "type" in v: + value[i] = TypedModel.parse_obj(v) super().__init__(**data)