-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontrol_flow_for_loop.yaml
More file actions
114 lines (97 loc) · 3.03 KB
/
control_flow_for_loop.yaml
File metadata and controls
114 lines (97 loc) · 3.03 KB
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
id: control-flow-for-loop
# For Loop Example
# Demonstrates iteration over a list of items
name: Batch File Processing
description: Process multiple files in parallel
version: "1.0.0"
parameters:
file_list:
type: array
default: ["file1.txt", "file2.txt", "file3.txt"]
description: List of files to process
output_dir:
type: string
default: "examples/outputs/control_flow_for_loop"
description: Output directory
steps:
# Create output directory
- id: create_output_dir
tool: filesystem
action: write
parameters:
path: "{{ output_dir }}/.gitkeep"
content: "# Output directory for batch processing"
# Process each file
- id: process_files
for_each: "{{ file_list }}"
max_parallel: 2
steps:
# Read the file
- id: read_file
tool: filesystem
action: read
parameters:
path: "data/{{ $item }}"
# Analyze file content
- id: analyze_content
action: analyze_text
parameters:
text: "{{ read_file.result.content }}"
model: <AUTO task="analyze">Select a model for text analysis</AUTO>
analysis_type: "summary"
dependencies:
- read_file
# Transform the content
- id: transform_content
action: generate_text
parameters:
prompt: |
Transform the following text to be more concise:
{{ read_file.result.content }}
Key points from analysis: {{ analyze_content.result }}
model: <AUTO task="generate">Select a model for text generation</AUTO>
max_tokens: 300
dependencies:
- analyze_content
# Save processed file
- id: save_file
tool: filesystem
action: write
parameters:
path: "{{ output_dir }}/processed_{{ $item }}"
content: |
# Processed: {{ $item }}
File index: {{ $index }}
Is first: {{ $is_first }}
Is last: {{ $is_last }}
## Original Size
{{ read_file.size }} bytes
## Analysis
{{ analyze_content.result }}
## Transformed Content
{{ transform_content.result }}
dependencies:
- transform_content
dependencies:
- create_output_dir
# Create summary report
- id: create_summary
tool: filesystem
action: write
parameters:
path: "{{ output_dir }}/summary.md"
content: |
# Batch Processing Summary
Total files processed: {{ file_list | length }}
## Files
{% for file in file_list %}
- {{ file }}
{% endfor %}
## Results
All files have been processed and saved to {{ output_dir }}/
dependencies:
- process_files
outputs:
processed_files: "{{ file_list | length }}"
output_directory: "{{ output_dir }}"
summary_file: "{{ create_summary.filepath }}"