File size: 21,362 Bytes
3fdcc70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
import os
import sys

sys.path.append(os.getcwd())

from cllm.agents.base import Action

BUILTIN_SEG_BY_POINTS = "Segment the given image based on the prompt points."
BUILTIN_SEG_BY_MASK = "Segment the given image based on the prompt mask."
# BUILTIN_REMOVE_BY_MASK = "Remove the object based on the given mask."
BUILTIN_IMAGE_TO_EDGE = "Generate the edge from the given image."
BUILTIN_GENERATE_SIMILAR_IMAGE = "Generate a new image similar to the input image"
# BUILTIN_GENERATE_SIMILAR_IMAGE2 = "Generate a similar image from the given image 2"
# BUILTIN_GENERATE_SIMILAR_IMAGE3 = "Image to image. 3"
BUILTIN_GENERATE_SIMILAR_IMAGE4 = "Generate a new image similar to image 4"
BUILTIN_GENERATE_IMAGE_HED = "Generate a new image based on HED result from input image"
BUILTIN_GENERATE_IMAGE_DEPTH = (
    "Generate a new image based on depth map from input image"
)
BUILTIN_GENERATE_IMAGE_OCR = "Please extract the text from the image"
BUILTIN_TEXT_EDGE_TO_IMAGE = "Generate an image based on the given edge map."
BUILTIN_GENERATE_IMAGE = "Generate a new image that shows a woman is skiing"
BUILTIN_IMAGE_TO_VIDEO = "Generate a video from the image"
BUILTIN_COUNT_OBJECTS = "Provide me with the count of bears in the input image"
BUILTIN_VIDEO_TO_WEBPAGE = "Generate a web page for input video"
BUILTIN_TEXT_TO_MUSIC = "Please generate a piece of music based on given prompt. Here is the prompt: An 80s driving pop song with heavy drums and synth pads in the background"
BUILTIN_IMAGE_ERASING1 = "Erase the wine glass from the photo"
BUILTIN_IMAGE_ERASING2 = "Erase the cats in the photo"
BUILTIN_IMAGE_CROPPING = "Crop the cats from the photo"
BUILTIN_IMAGE_SEG = "give me the mask of elephant."
BUILTIN_IMAGE_HIGHLIGHT = "highlight the elephant."
BUILTIN_TEXT_SPEECH = "translate text into speech"
BUILTIN_DUBBING = "dub this video with the given audio"
BUILTIN_COUNT_OBJECTS2 = "Count the horse in the image."
BUILTIN_IMAGE_TO_VIDEO2 = "Generate an image that shows a serene and beautiful landscape with a calm lake reflecting the blue sky and white clouds. Then generate a video to introduce this image."
BUILTIN_IMAGE_TO_VIDEO3 = "Create a visual and auditory representation of a peaceful and scenic landscape. The image should depict a serene and beautiful landscape with a calm lake reflecting the blue sky. The music should match the image. Finally, combine the image and the music into a video that showcases the beauty of nature."
BUILTIN_VIDEO_CLS = "Recognize the action in the video"
BUILTIN_VIDEO_CLS = "Recognize the action in the video"
BUILTIN_AUDIO_CLS = "Recognize the event in this audio"
BUILTIN_IMAGE2MUSIC = "Generate a piece of music for this image"
BUILTIN_VIDEO2MUSIC = (
    "Generate a piece of music for this video and dub the video with generated music"
)

BUILTIN_PLANS = {
    # BUILTIN_REMOVE_BY_MASK: [
    #     [
    #         Action(
    #             tool_name="image_inpainting",
    #             inputs={"image": "image", "mask": "image.mask"},
    #             outputs=["<GENERATED>-0"],
    #         )
    #     ]
    # ],
    BUILTIN_IMAGE_TO_EDGE: [
        [
            Action(
                tool_name="image_to_edge",
                inputs={"image": "image"},
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    BUILTIN_TEXT_EDGE_TO_IMAGE: [
        [
            Action(
                tool_name="image_captioning",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-prompt"],
            ),
            Action(
                tool_name="edge_text_to_image",
                inputs={
                    "edge": "image.edge",
                    "text": "<TOOL-GENERATED>-prompt",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_GENERATE_SIMILAR_IMAGE: [
        [
            Action(
                tool_name="image_to_edge",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-edge"],
            ),
            Action(
                tool_name="image_captioning",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-prompt"],
            ),
            Action(
                tool_name="edge_text_to_image",
                inputs={
                    "edge": "<TOOL-GENERATED>-edge",
                    "text": "<TOOL-GENERATED>-prompt",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    # BUILTIN_GENERATE_SIMILAR_IMAGE2: [
    #     [
    #         Action(
    #             tool_name="image_captioning",
    #             inputs={"image": "image"},
    #             outputs=["<TOOL-GENERATED>-prompt"],
    #         ),
    #         Action(
    #             tool_name="text_to_image",
    #             inputs={"text": "<TOOL-GENERATED>-prompt"},
    #             outputs=["<GENERATED>-0"],
    #         ),
    #     ]
    # ],
    # BUILTIN_GENERATE_SIMILAR_IMAGE3: [
    #     [
    #         Action(
    #             tool_name="image_to_image",
    #             inputs={"image": "image"},
    #             outputs=["<GENERATED>-0"],
    #         ),
    #     ]
    # ],
    BUILTIN_GENERATE_IMAGE_HED: [
        [
            Action(
                tool_name="image_to_hed",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-image_to_hed-hed-0"],
            ),
            Action(
                tool_name="hed_text_to_image",
                inputs={
                    "text": "beautiful mountains and sunset",
                    "hed": "<TOOL-GENERATED>-image_to_hed-hed-0",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_GENERATE_IMAGE_DEPTH: [
        [
            Action(
                tool_name="image_captioning",
                inputs={
                    "image": "image",
                },
                outputs=["<TOOL-GENERATED>-image_captioning-text-0"],
            ),
            Action(
                tool_name="image_to_depth",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-image_to_depth-depth-0"],
            ),
            Action(
                tool_name="depth_text_to_image",
                inputs={
                    "text": "<TOOL-GENERATED>-image_captioning-text-0",
                    "depth": "<TOOL-GENERATED>-image_to_depth-depth-0",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_GENERATE_IMAGE_OCR: [
        [
            Action(
                tool_name="optical_character_recognition",
                inputs={"image": "image"},
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    BUILTIN_COUNT_OBJECTS: [
        [
            Action(
                tool_name="object_detection",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-object_detection-bbox-0"],
            ),
            Action(
                tool_name="select_bbox",
                inputs={
                    "bbox_list": "<TOOL-GENERATED>-object_detection-bbox-0",
                    "condition": "bear",
                },
                outputs=["<TOOL-GENERATED>-select_bbox-bbox-0"],
            ),
            Action(
                tool_name="count_objects",
                inputs={"bbox_list": "<TOOL-GENERATED>-select_bbox-bbox-0"},
                outputs=["<GENERATED>-0"],
            ),
        ],
        [
            Action(
                tool_name="image_question_answering",
                inputs={
                    "text": "Provide me with the count of bears in the input image",
                    "image": "image",
                },
                outputs=["<GENERATED>-1"],
            )
        ],
    ],
    BUILTIN_VIDEO_TO_WEBPAGE: [
        [
            Action(
                tool_name="video_captioning",
                inputs={"video": "video"},
                outputs=["<TOOL-GENERATED>-text-0"],
            ),
            Action(
                tool_name="text_to_music",
                inputs={"text": "<TOOL-GENERATED>-text-0"},
                outputs=["<TOOL-GENERATED>-text_to_music-audio-0"],
            ),
            Action(
                tool_name="dub_video",
                inputs={
                    "video": "video",
                    "audio": "<TOOL-GENERATED>-text_to_music-audio-0",
                },
                outputs=["<TOOL-GENERATED>-dub_video-video-0"],
            ),
            Action(
                tool_name="title_generation",
                inputs={"text": "<TOOL-GENERATED>-text-0"},
                outputs=["<TOOL-GENERATED>-text-1"],
            ),
            Action(
                tool_name="text_to_tags",
                inputs={"text": "<TOOL-GENERATED>-text-0"},
                outputs=["<TOOL-GENERATED>-tags-0"],
            ),
            Action(
                tool_name="video_to_webpage",
                inputs={
                    "video": "<TOOL-GENERATED>-dub_video-video-0",
                    "title": "<TOOL-GENERATED>-text-1",
                    "tags": "<TOOL-GENERATED>-tags-0",
                    "description": "<TOOL-GENERATED>-text-0",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_TEXT_TO_MUSIC: [
        [
            Action(
                tool_name="text_to_music",
                inputs={
                    "text": "An 80s driving pop song with heavy drums and synth pads in the background"
                },
                outputs=["<GENERATED>-audio-0"],
            )
        ]
    ],
    BUILTIN_IMAGE_ERASING1: [
        [
            Action(
                tool_name="image_instance_segmentation",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-image_instance_segmentation-mask-0"],
            ),
            Action(
                tool_name="select_mask",
                inputs={
                    "mask_list": "<TOOL-GENERATED>-image_instance_segmentation-mask-0",
                    "condition": "wine glass",
                },
                outputs=["<TOOL-GENERATED>-select_mask-mask-1"],
            ),
            Action(
                tool_name="image_inpainting",
                inputs={
                    "image": "image",
                    "mask": "<TOOL-GENERATED>-select_mask-mask-0",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_IMAGE_ERASING2: [
        [
            Action(
                tool_name="image_instance_segmentation",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-image_instance_segmentation-mask-0"],
            ),
            Action(
                tool_name="select_mask",
                inputs={
                    "mask_list": "<TOOL-GENERATED>-image_instance_segmentation-mask-0",
                    "condition": "cat",
                },
                outputs=["<TOOL-GENERATED>-select_mask-mask-0"],
            ),
            Action(
                tool_name="image_inpainting",
                inputs={
                    "image": "image",
                    "mask": "<TOOL-GENERATED>-select_mask-mask-0",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_IMAGE_CROPPING: [
        [
            Action(
                tool_name="object_detection",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-object_detection-bbox-0"],
            ),
            Action(
                tool_name="select_bbox",
                inputs={
                    "bbox_list": "<TOOL-GENERATED>-object_detection-bbox-0",
                    "condition": "cat",
                },
                outputs=["<TOOL-GENERATED>-select_bbox-bbox-0"],
            ),
            Action(
                tool_name="image_cropping",
                inputs={
                    "image": "image",
                    "object": "<TOOL-GENERATED>-select_bbox-bbox-0",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_IMAGE_SEG: [
        [
            Action(
                tool_name="image_instance_segmentation",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-image_instance_segmentation-mask-0"],
            ),
            Action(
                tool_name="select_mask",
                inputs={
                    "mask_list": "<TOOL-GENERATED>-image_instance_segmentation-mask-0",
                    "condition": "elephant",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_IMAGE_HIGHLIGHT: [
        [
            Action(
                tool_name="object_detection",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-object_detection-bbox-0"],
            ),
            Action(
                tool_name="select_bbox",
                inputs={
                    "bbox_list": "<TOOL-GENERATED>-object_detection-bbox-0",
                    "condition": "elephant",
                },
                outputs=["<TOOL-GENERATED>-select_bbox-bbox-0"],
            ),
            Action(
                tool_name="highlight_object_on_image",
                inputs={
                    "image": "image",
                    "bbox": "<TOOL-GENERATED>-select_bbox-bbox-0",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_TEXT_SPEECH: [
        [
            Action(
                tool_name="text_to_speech",
                inputs={
                    "text": "Hope is the thing with feathers That perches in the soul, And sings the tune without the words, And never stops at all"
                },
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    BUILTIN_DUBBING: [
        [
            Action(
                tool_name="dub_video",
                inputs={"video": "video", "audio": "audio"},
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    BUILTIN_GENERATE_SIMILAR_IMAGE4: [
        [
            Action(
                tool_name="segment_anything",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-seg"],
            ),
            Action(
                tool_name="image_captioning",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-prompt"],
            ),
            Action(
                tool_name="segmentation_text_to_image",
                inputs={
                    "segmentation": "<TOOL-GENERATED>-seg",
                    "text": "<TOOL-GENERATED>-prompt",
                },
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_GENERATE_IMAGE: [
        [
            Action(
                tool_name="text_to_image",
                inputs={"text": "a woman is skiing"},
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    BUILTIN_IMAGE_TO_VIDEO: [
        [
            Action(
                tool_name="image_to_video",
                inputs={"image": "image"},
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    BUILTIN_COUNT_OBJECTS2: [
        [
            Action(
                tool_name="object_detection",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-object_detection-bbox-0"],
            ),
            Action(
                tool_name="select_bbox",
                inputs={
                    "bbox_list": "<TOOL-GENERATED>-object_detection-bbox-0",
                    "condition": "horse",
                },
                outputs=["<TOOL-GENERATED>-select_bbox-bbox-0"],
            ),
            Action(
                tool_name="count_objects",
                inputs={"bbox_list": "<TOOL-GENERATED>-select_bbox-bbox-0"},
                outputs=["<GENERATED>-0"],
            ),
        ],
        [
            Action(
                tool_name="image_question_answering",
                inputs={
                    "text": "Provide me with the count of horses in the input image",
                    "image": "image",
                },
                outputs=["<GENERATED>-1"],
            )
        ],
    ],
    BUILTIN_IMAGE_TO_VIDEO2: [
        [
            Action(
                tool_name="text_to_image",
                inputs={
                    "text": "A serene and beautiful landscape with a calm lake reflecting the blue sky and white clouds."
                },
                outputs=["<GENERATED>-0"],
            ),
        ],
        [
            Action(
                tool_name="image_captioning",
                inputs={"image": "<GENERATED>-0"},
                outputs=["<TOOL-GENERATED>-text-0"],
            ),
            Action(
                tool_name="text_to_speech",
                inputs={"text": "<TOOL-GENERATED>-text-0"},
                outputs=["<TOOL-GENERATED>-text_to_speech-audio-0"],
            ),
            Action(
                tool_name="image_audio_to_video",
                inputs={
                    "image": "<GENERATED>-0",
                    "audio": "<TOOL-GENERATED>-text_to_speech-audio-0",
                },
                outputs=["<GENERATED>-1"],
            ),
        ],
    ],
    BUILTIN_IMAGE_TO_VIDEO3: [
        [
            Action(
                tool_name="text_to_image",
                inputs={
                    "text": "A serene and beautiful landscape with a calm lake reflecting the blue sky."
                },
                outputs=["<GENERATED>-0"],
            ),
        ],
        [
            Action(
                tool_name="image_captioning",
                inputs={"image": "<GENERATED>-0"},
                outputs=["<TOOL-GENERATED>-text-0"],
            ),
            Action(
                tool_name="text_to_music",
                inputs={"text": "<TOOL-GENERATED>-text-0"},
                outputs=["<GENERATED>-1"],
            ),
        ],
        [
            Action(
                tool_name="image_to_video",
                inputs={
                    "image": "<GENERATED>-0",
                },
                outputs=["<TOOL-GENERATED>-image_to_video-video-0"],
            ),
            Action(
                tool_name="dub_video",
                inputs={
                    "video": "<TOOL-GENERATED>-image_to_video-video-0",
                    "audio": "<GENERATED>-1",
                },
                outputs=["<GENERATED>-2"],
            ),
        ],
    ],
    BUILTIN_VIDEO_CLS: [
        [
            Action(
                tool_name="video_classification",
                inputs={"video": "video"},
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    BUILTIN_AUDIO_CLS: [
        [
            Action(
                tool_name="audio_classification",
                inputs={"audio": "audio"},
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    BUILTIN_IMAGE2MUSIC: [
        [
            Action(
                tool_name="image_captioning",
                inputs={"image": "image"},
                outputs=["<TOOL-GENERATED>-text-0"],
            ),
            Action(
                tool_name="text_to_music",
                inputs={"text": "<TOOL-GENERATED>-text-0"},
                outputs=["<GENERATED>-0"],
            ),
        ]
    ],
    BUILTIN_VIDEO2MUSIC: [
        [
            Action(
                tool_name="video_captioning",
                inputs={"video": "video"},
                outputs=["<TOOL-GENERATED>-text-0"],
            ),
            Action(
                tool_name="text_to_music",
                inputs={"text": "<TOOL-GENERATED>-text-0"},
                outputs=["<GENERATED>-0"],
            ),
        ],
        [
            Action(
                tool_name="dub_video",
                inputs={
                    "video": "video",
                    "audio": "<GENERATED>-0",
                },
                outputs=["<GENERATED>-1"],
            ),
        ],
    ],
    BUILTIN_SEG_BY_POINTS: [
        [
            Action(
                tool_name="image_segmentation_by_points",
                inputs={"image": "image", "prompt_points": "prompt_points"},
                outputs=["<GENERATED>-0"],
            )
        ]
    ],
    # BUILTIN_SEG_BY_MASK: [
    #     [
    #         Action(
    #             tool_name='image_segmentation_by_mask',
    #             inputs={'image': 'image', 'prompt_mask': 'prompt_mask'},
    #             outputs=['<GENERATED>-0'],
    #         )
    #     ]
    # ],
}


def load_builtin_plans(path):
    import json

    plans = json.load(open(path, "r"))
    processed_plan = {}
    for query, actions in plans.items():
        actions2 = []
        for ac in actions[0]:
            actions2.append(
                Action(
                    tool_name=ac["tool_name"],
                    inputs=ac["inputs"],
                    outputs=ac["outputs"],
                ),
            )
        processed_plan[query] = [actions2]
    return processed_plan