Files
Claude AI 8824f65a62 feat(fase2): add Flow schemas and Flow Engine core
API Gateway:
- Add Pydantic schemas for Flow API (create, update, response, nodes, edges)

Flow Engine:
- Add FlowContext for variable management and interpolation
- Add FlowEngine for executing chatbot flows
- Support node types: trigger, message, buttons, wait_input, condition, set_variable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:19:11 +00:00

75 lines
1.5 KiB
Python

from pydantic import BaseModel
from typing import Optional, List
from uuid import UUID
from datetime import datetime
from app.models.flow import TriggerType
class NodeData(BaseModel):
label: str
type: str
config: dict = {}
class FlowNode(BaseModel):
id: str
type: str
position: dict
data: NodeData
class FlowEdge(BaseModel):
id: str
source: str
target: str
sourceHandle: Optional[str] = None
targetHandle: Optional[str] = None
class FlowCreate(BaseModel):
name: str
description: Optional[str] = None
trigger_type: TriggerType
trigger_value: Optional[str] = None
class FlowUpdate(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
trigger_type: Optional[TriggerType] = None
trigger_value: Optional[str] = None
nodes: Optional[List[dict]] = None
edges: Optional[List[dict]] = None
variables: Optional[dict] = None
is_active: Optional[bool] = None
class FlowResponse(BaseModel):
id: UUID
name: str
description: Optional[str]
trigger_type: TriggerType
trigger_value: Optional[str]
nodes: List[dict]
edges: List[dict]
variables: dict
is_active: bool
version: int
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
class FlowListResponse(BaseModel):
id: UUID
name: str
trigger_type: TriggerType
is_active: bool
version: int
updated_at: datetime
class Config:
from_attributes = True