Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makes ActionConfig a TypedModel #301

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions playground/streaming/agent/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions vocode/streaming/action/nylas_send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
)


class NylasSendEmailActionConfig(ActionConfig):
type = ActionType.NYLAS_SEND_EMAIL
class NylasSendEmailActionConfig(ActionConfig, type=ActionType.NYLAS_SEND_EMAIL):
pass


class NylasSendEmailParameters(BaseModel):
Expand Down
9 changes: 5 additions & 4 deletions vocode/streaming/models/actions.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
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):
BASE = "action_base"
NYLAS_SEND_EMAIL = "action_nylas_send_email"


class ActionConfig(TypedModel, type=ActionType.BASE):
pass


ParametersType = TypeVar("ParametersType", bound=BaseModel)


Expand Down
5 changes: 5 additions & 0 deletions vocode/streaming/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
Loading