File size: 5,766 Bytes
176823e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# Define Schema

Before using the Flow component, need to create a Schema definition node in advance. The schema type is defined as follows:

```ts
export interface FlowSchema {
  nodes: FlowNodeSchema[];
}

export interface FlowNodeSchema {
  /**
   * As a unique identifier for the node. Mandatory.
   */
  name: string;

  /**
   * Display icon for the node.
   */
  icon?: string;

  /**
   * Display title for the node, defaults to the node name if not provided.
   */
  title?: string;

  /**
   * A short description of the node's purpose.
   */
  description?: string;

  /**
   * Width of the node.
   */
  width?: number;

  /**
   * Height of the node.
   */
  height?: number;

  /**
   * Shows/hides the toolbar (delete, copy, rename, etc.).
   * @default true
   */
  show_toolbar?: boolean;

  /**
   * Enables/disables adding more instances of this node.
   * @default true
   */
  addable?: boolean;

  /**
   * Enables/disables deleting existing instances of this node.
   * @default true
   */
  deletable?: boolean;

  /**
   * Maximum number of this node type that can exist simultaneously.
   */
  max?: number;

  /**
   * Minimum number of this node type that must exist simultaneously.
   */
  min?: number;

  /**
   * Configurations for the node's connection ports.
   */
  ports?: {
    /**
     * Source ports for the node as a connection.
     * @default ['right']
     */
    source?: Position[];

    /**
     * Allowed the source ports of this node to connect to other nodes or attributes. Defaults to all nodes and attributes
     */
    sourceConnections?: PortConnection[];

    /**
     * Target ports for the node as a connection
     * @default ['left']
     */
    target?: Position[];

    /**
     * Allowed other nodes or attributes allowed to connect to the target ports of this node. Defaults to all nodes and attributes
     *
     */
    targetConnections?: PortConnection[];
  };

  /**
   * Configuration of the node's attributes.
   */
  attrs?: FlowNodeAttrSchema[];

  /**
   * Initial values for the node's attributes when creating a new instance.
   */
  template?: {
    /**
     * Attribute values corresponding to their names in the `attrs` field, e.g., `{ "a": 1, "b": 2 }`.
     */
    attrs?: Attrs;
  };
}

export interface FlowNodeAttrSchema {
  /**
   * Unique attribute name used as a key in the node data. Mandatory.
   */
  name: string;

  /**
   * Display title for the attribute, defaults to the attribute name if not provided.
   */
  title?: string;

  /**
   * A brief explanation about the attribute purpose.
   */
  description?: string;

  /**
   * Disables user editing of the attribute value. By default, attributes are editable.
   * @default false
   */
  disabled?: boolean;

  /**
   * Attribute input type. Can be one of the built-in Ant Design components or a custom component. Defaults to 'input'.
   * @default 'input'
   */
  type?:
    | 'input'
    | 'textarea'
    | 'radio'
    | 'checkbox'
    | 'number'
    | 'select'
    | 'switch'
    | 'upload'
    // custom
    | (string & {});

  /**
   * Configuration options specific to the chosen component type, supporting Ant Design ({@link https://ant.design/components/overview/}) or custom component properties.
   */
  props?: Record<string, any>;

  /**
   * Configurations for the node attribute ports.
   */
  ports?: {
    /**
     * Source ports for the attribute as a connection.
     * @default []
     */
    source?: Position[];

    /**
     * Allowed the source ports of this attribute to connect to other nodes or attributes. Defaults to all nodes and attributes
     */
    sourceConnections?: PortConnection[];

    /**
     * Target ports for the attribute as a connection
     * @default []
     */
    target?: Position[];

    /**
     * Allowed other nodes or attributes allowed to connect to the target ports of this attribute. Defaults to all nodes and attributes
     */
    targetConnections?: PortConnection[];
  };

  /**
   * Indicates whether the attribute is a list.
   * @default false
   */
  list?:
    | boolean
    | {
        /**
         * Port configurations for each item in the list.
         */
        ports?: {
          /**
           * Source ports for the list item as a connection.
           * @default []
           */
          source?: Position[];

          /**
           * Allowed the source ports of this list item to connect to other nodes or attributes. Defaults to all nodes and attributes
           */
          sourceConnections?: PortConnection[];

          /**
           * Target ports for the list item as a connection
           */
          target?: Position[];

          /**
           * Allowed other nodes or attributes allowed to connect to the target ports of this list item. Defaults to all nodes and attributes
           */
          targetConnections?: PortConnection[];
        };

        /**
         * Minimum number of items in the list.
         */
        min?: number;

        /**
         * Maximum number of items in the list.
         */
        max?: number;
      };

  /**
   * Enable/disable accordion UI.
   * @default true
   */
  accordion?: boolean;

  /**
   * Specifies if the attribute value is mandatory. By default, attributes are optional.
   * @default false
   */
  required?:
    | boolean
    | {
        message?: string;
      };

  /**
   * Validates attribute values using JSON schema.
   */
  json_schema_validator?: Record<string, any>;
}
```

You can define the schema by a json file (recommended) or directly on the Python by the exported types:

- Defined by json:

```json
<file src="./schema/agents_schema.json"></file>
```

- Defined by Python:

```python
<file src="./schema/agents_schema.py"></file>
```