NodeData

 1# NodeData.py
 2
 3from dataclasses import dataclass, asdict, field
 4from typing import List
 5
 6@dataclass
 7class Serializable:
 8    def to_dict(self):
 9        return asdict(self)
10    
11    @classmethod
12    def from_dict(cls, data):
13        return cls(**data)
14
15@dataclass
16class NodeData(Serializable):
17    
18    # "None", "Start", "Agent", "Task", "Step", "Team"
19    type: str = ""
20
21    uniq_id: str = ""
22    pos_x: float = 0.0
23    pos_y: float = 0.0
24    width: float = 200.0  # Default width
25    height: float = 200.0  # Default height
26
27    name: str = ""
28
29    # Agent
30    role: str = ""
31    goal: str = ""
32    backstory: str = ""
33
34    # Task
35    agent: str = ""
36    description: str = ""
37    expected_output: str = ""
38
39    # Step
40    tool: str = ""
41    arg: str = ""
42    output_var: str = ""
43
44
45    nexts: List[int] = field(default_factory=list)
46    prevs: List[int] = field(default_factory=list)
47
48    def to_dict(self):
49        return asdict(self)
50
51    @classmethod
52    def from_dict(cls, data):
53        return cls(**data)
@dataclass
class Serializable:
 7@dataclass
 8class Serializable:
 9    def to_dict(self):
10        return asdict(self)
11    
12    @classmethod
13    def from_dict(cls, data):
14        return cls(**data)
def to_dict(self):
 9    def to_dict(self):
10        return asdict(self)
@classmethod
def from_dict(cls, data):
12    @classmethod
13    def from_dict(cls, data):
14        return cls(**data)
@dataclass
class NodeData(Serializable):
16@dataclass
17class NodeData(Serializable):
18    
19    # "None", "Start", "Agent", "Task", "Step", "Team"
20    type: str = ""
21
22    uniq_id: str = ""
23    pos_x: float = 0.0
24    pos_y: float = 0.0
25    width: float = 200.0  # Default width
26    height: float = 200.0  # Default height
27
28    name: str = ""
29
30    # Agent
31    role: str = ""
32    goal: str = ""
33    backstory: str = ""
34
35    # Task
36    agent: str = ""
37    description: str = ""
38    expected_output: str = ""
39
40    # Step
41    tool: str = ""
42    arg: str = ""
43    output_var: str = ""
44
45
46    nexts: List[int] = field(default_factory=list)
47    prevs: List[int] = field(default_factory=list)
48
49    def to_dict(self):
50        return asdict(self)
51
52    @classmethod
53    def from_dict(cls, data):
54        return cls(**data)
NodeData( type: str = '', uniq_id: str = '', pos_x: float = 0.0, pos_y: float = 0.0, width: float = 200.0, height: float = 200.0, name: str = '', role: str = '', goal: str = '', backstory: str = '', agent: str = '', description: str = '', expected_output: str = '', tool: str = '', arg: str = '', output_var: str = '', nexts: List[int] = <factory>, prevs: List[int] = <factory>)
type: str = ''
uniq_id: str = ''
pos_x: float = 0.0
pos_y: float = 0.0
width: float = 200.0
height: float = 200.0
name: str = ''
role: str = ''
goal: str = ''
backstory: str = ''
agent: str = ''
description: str = ''
expected_output: str = ''
tool: str = ''
arg: str = ''
output_var: str = ''
nexts: List[int]
prevs: List[int]
def to_dict(self):
49    def to_dict(self):
50        return asdict(self)
@classmethod
def from_dict(cls, data):
52    @classmethod
53    def from_dict(cls, data):
54        return cls(**data)