File size: 2,528 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
import os

from modelscope_studio.components.Flow import (
    FlowSchemaDict, NodeSchemaAttributeDict, NodeSchemaAttributeListDict,
    NodeSchemaAttributeRequiredDict, NodeSchemaDict, NodeSchemaPortsDict,
    NodeSchemaTemplateDict)


def resolve_assets(relative_path):
    return os.path.join(os.path.dirname(__file__), "../../resources",
                        relative_path)


schema = FlowSchemaDict(nodes=[
    NodeSchemaDict(max=1,
                   min=1,
                   addable=False,
                   show_toolbar=False,
                   name="start",
                   title="Start",
                   ports=NodeSchemaPortsDict(source=['right'], target=[])),
    NodeSchemaDict(
        icon=resolve_assets('./bot.jpeg'),
        name="agent",
        title="Agent Node",
        description="Agent Flow Node",
        ports=NodeSchemaPortsDict(source=[], target=['left']),
        attrs=[
            NodeSchemaAttributeDict(name="prompt",
                                    title="Agent Prompt",
                                    type='textarea',
                                    required=NodeSchemaAttributeRequiredDict(
                                        message="Agent Prompt is required")),
            NodeSchemaAttributeDict(name="tool",
                                    title="Tools",
                                    type="select",
                                    props={
                                        "mode":
                                        "multiple",
                                        "options": [{
                                            "label": "Wanx Image Generation",
                                            "value": "image_gen"
                                        }, {
                                            "label": "Code Interpreter",
                                            "value": "code_interpreter"
                                        }, {
                                            "label": "Web Browsing",
                                            "value": "web_browser"
                                        }]
                                    }),
            NodeSchemaAttributeDict(
                name="condition",
                title="Jump Condition",
                list=NodeSchemaAttributeListDict(
                    min=1, ports=NodeSchemaPortsDict(source=['right'])),
                accordion=False)
        ],
        template=NodeSchemaTemplateDict(attrs=dict(condition=[''])))
])