chain model

This commit is contained in:
Robert 2024-02-25 10:42:38 +07:00
parent 1770b43c2f
commit 76ef312267
No known key found for this signature in database
GPG Key ID: F631C7FD957D5F22

View File

@ -0,0 +1,29 @@
from .base import BaseMongoModel
from datetime import datetime
from pydantic import BaseModel, Field
from typing import Literal, Union, Annotated, Optional, List
class WaitAction(BaseModel):
action_type: Literal["wait"]
wait_for: int
class TextCommentAction(BaseModel):
action_type: Literal["text_comment"]
text: str
Action = Annotated[
Union[WaitAction, TextCommentAction], Field(description="action_type")
]
class Chain(BaseMongoModel):
name: Annotated[Optional[str], Field(default=None)]
actions: Annotated[Optional[List[Action]], Field(default=[])]
created_at: Annotated[datetime, Field(default_factory=datetime.utcnow)]
class Config(BaseMongoModel.Config):
pass