pytrace/server/app/models/graph.py

26 lines
770 B
Python
Raw Permalink Normal View History

2026-01-15 21:58:30 +08:00
from pydantic import BaseModel
from typing import List, Dict, Any, Optional
from pytrace.model.enums import NodeType, DimensionMode
class NodeSchema(BaseModel):
"""Data structure for a node in a graph request."""
id: str
type: str # This corresponds to the NodeSpec's 'type' field
name: str
params: Optional[Dict[str, Any]] = {}
class EdgeSchema(BaseModel):
"""Data structure for an edge in a graph request."""
2026-01-19 00:49:55 +08:00
source_id: str
2026-01-15 21:58:30 +08:00
source_port: str
2026-01-19 00:49:55 +08:00
target_id: str
2026-01-15 21:58:30 +08:00
target_port: str
class GraphExecuteRequest(BaseModel):
"""Request model for graph execution."""
nodes: List[NodeSchema]
edges: List[EdgeSchema]
# initial_inputs could be provided to kickstart the graph
initial_inputs: Optional[Dict[str, Any]] = {}